File tree 2 files changed +17
-1
lines changed
tests/unit/Codeception/Module 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1971,7 +1971,10 @@ public function grabTextFrom($cssOrXPathOrRegex)
1971
1971
return $ els [0 ]->getText ();
1972
1972
}
1973
1973
1974
- if (@preg_match ($ cssOrXPathOrRegex , $ this ->webDriver ->getPageSource (), $ matches )) {
1974
+ if (
1975
+ is_string ($ cssOrXPathOrRegex )
1976
+ && @preg_match ($ cssOrXPathOrRegex , $ this ->webDriver ->getPageSource (), $ matches )
1977
+ ) {
1975
1978
return $ matches [1 ];
1976
1979
}
1977
1980
Original file line number Diff line number Diff line change @@ -706,6 +706,19 @@ public function testGrabTextFrom()
706
706
$ this ->assertSame ('test ' , $ result );
707
707
}
708
708
709
+ public function testGrabTextFromWithArraySelectorForExistingElement ()
710
+ {
711
+ $ this ->module ->amOnPage ('/ ' );
712
+ $ this ->assertSame ('More info ' , $ this ->module ->grabTextFrom (['id ' => 'link ' ]));
713
+ }
714
+
715
+ public function testGrabTextFromWithArraySelectorForNonExistentElement ()
716
+ {
717
+ $ this ->module ->amOnPage ('/ ' );
718
+ $ this ->expectException ('Codeception\Exception\ElementNotFound ' );
719
+ $ this ->module ->grabTextFrom (['id ' => 'unknown_link ' ]);
720
+ }
721
+
709
722
public function testGrabValueFrom ()
710
723
{
711
724
$ this ->module ->amOnPage ('/form/hidden ' );
You can’t perform that action at this time.
0 commit comments