@@ -912,14 +912,9 @@ class WebDriver extends Helper {
912
912
async grabTextFrom ( locator ) {
913
913
const res = await this . _locate ( locator , true ) ;
914
914
assertElementExists ( res , locator ) ;
915
- let val ;
916
- if ( res . length > 1 ) {
917
- val = await forEachAsync ( res , async el => this . browser . getElementText ( getElementId ( el ) ) ) ;
918
- } else {
919
- val = await this . browser . getElementText ( getElementId ( res [ 0 ] ) ) ;
920
- }
921
- this . debugSection ( 'Grab' , val ) ;
922
- return val ;
915
+ const val = await forEachAsync ( res , el => this . browser . getElementText ( getElementId ( el ) ) ) ;
916
+ this . debugSection ( 'Grab' , String ( val ) ) ;
917
+ return val . length > 1 ? val : val [ 0 ] ;
923
918
}
924
919
925
920
/**
@@ -929,12 +924,9 @@ class WebDriver extends Helper {
929
924
async grabHTMLFrom ( locator ) {
930
925
const elems = await this . _locate ( locator , true ) ;
931
926
assertElementExists ( elems , locator ) ;
932
- const values = await Promise . all ( elems . map ( elem => elem . getHTML ( false ) ) ) ;
933
- this . debugSection ( 'Grab' , values ) ;
934
- if ( Array . isArray ( values ) && values . length === 1 ) {
935
- return values [ 0 ] ;
936
- }
937
- return values ;
927
+ const val = await forEachAsync ( elems , elem => elem . getHTML ( false ) ) ;
928
+ this . debugSection ( 'Grab' , String ( val ) ) ;
929
+ return val . length > 1 ? val : val [ 0 ] ;
938
930
}
939
931
940
932
/**
@@ -944,8 +936,9 @@ class WebDriver extends Helper {
944
936
async grabValueFrom ( locator ) {
945
937
const res = await this . _locate ( locator , true ) ;
946
938
assertElementExists ( res , locator ) ;
947
-
948
- return forEachAsync ( res , async el => el . getValue ( ) ) ;
939
+ const val = await forEachAsync ( res , el => el . getValue ( ) ) ;
940
+ this . debugSection ( 'Grab' , String ( val ) ) ;
941
+ return val . length > 1 ? val : val [ 0 ] ;
949
942
}
950
943
951
944
/**
@@ -954,7 +947,9 @@ class WebDriver extends Helper {
954
947
async grabCssPropertyFrom ( locator , cssProperty ) {
955
948
const res = await this . _locate ( locator , true ) ;
956
949
assertElementExists ( res , locator ) ;
957
- return forEachAsync ( res , async el => this . browser . getElementCSSValue ( getElementId ( el ) , cssProperty ) ) ;
950
+ const val = await forEachAsync ( res , async el => this . browser . getElementCSSValue ( getElementId ( el ) , cssProperty ) ) ;
951
+ this . debugSection ( 'Grab' , String ( val ) ) ;
952
+ return val . length > 1 ? val : val [ 0 ] ;
958
953
}
959
954
960
955
/**
@@ -964,7 +959,9 @@ class WebDriver extends Helper {
964
959
async grabAttributeFrom ( locator , attr ) {
965
960
const res = await this . _locate ( locator , true ) ;
966
961
assertElementExists ( res , locator ) ;
967
- return forEachAsync ( res , async el => el . getAttribute ( attr ) ) ;
962
+ const val = await forEachAsync ( res , async el => el . getAttribute ( attr ) ) ;
963
+ this . debugSection ( 'Grab' , String ( val ) ) ;
964
+ return val . length > 1 ? val : val [ 0 ] ;
968
965
}
969
966
970
967
/**
0 commit comments