File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
tests/unit/Codeception/Module Expand file tree Collapse file tree 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)
19711971 return $ els [0 ]->getText ();
19721972 }
19731973
1974- if (@preg_match ($ cssOrXPathOrRegex , $ this ->webDriver ->getPageSource (), $ matches )) {
1974+ if (
1975+ is_string ($ cssOrXPathOrRegex )
1976+ && @preg_match ($ cssOrXPathOrRegex , $ this ->webDriver ->getPageSource (), $ matches )
1977+ ) {
19751978 return $ matches [1 ];
19761979 }
19771980
Original file line number Diff line number Diff line change @@ -706,6 +706,19 @@ public function testGrabTextFrom()
706706 $ this ->assertSame ('test ' , $ result );
707707 }
708708
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+
709722 public function testGrabValueFrom ()
710723 {
711724 $ this ->module ->amOnPage ('/form/hidden ' );
You can’t perform that action at this time.
0 commit comments