File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 13
13
14
14
namespace Symfony \Component \Panther ;
15
15
16
+ use Facebook \WebDriver \Exception \NoSuchElementException ;
17
+ use Facebook \WebDriver \Exception \TimeOutException ;
18
+ use Facebook \WebDriver \Remote \RemoteWebElement ;
16
19
use Facebook \WebDriver \WebDriver ;
17
20
use Facebook \WebDriver \WebDriverBy ;
18
21
use Facebook \WebDriver \WebDriverCapabilities ;
@@ -226,7 +229,13 @@ public function getCookieJar()
226
229
return new CookieJar ($ this ->webDriver );
227
230
}
228
231
229
- public function waitFor (string $ cssSelector , int $ timeoutInSecond = 30 , int $ intervalInMillisecond = 250 ): object
232
+ /**
233
+ * @throws NoSuchElementException
234
+ * @throws TimeOutException
235
+ *
236
+ * @return RemoteWebElement
237
+ */
238
+ public function waitFor (string $ cssSelector , int $ timeoutInSecond = 30 , int $ intervalInMillisecond = 250 )
230
239
{
231
240
return $ this ->wait ($ timeoutInSecond , $ intervalInMillisecond )->until (
232
241
WebDriverExpectedCondition::visibilityOfElementLocated (WebDriverBy::cssSelector ($ cssSelector ))
Original file line number Diff line number Diff line change 13
13
14
14
namespace Symfony \Component \Panther \Tests ;
15
15
16
+ use Facebook \WebDriver \Remote \RemoteWebElement ;
16
17
use Facebook \WebDriver \WebDriver ;
17
18
use Symfony \Component \BrowserKit \Client as BrowserKitClient ;
18
19
use Symfony \Component \BrowserKit \Cookie ;
@@ -34,6 +35,15 @@ public function testCreateClient()
34
35
$ this ->assertInstanceOf (WebDriver::class, $ client );
35
36
}
36
37
38
+ public function testWaitFor ()
39
+ {
40
+ $ client = self ::createPantherClient ();
41
+ $ crawler = $ client ->request ('GET ' , '/waitfor.html ' );
42
+ $ c = $ client ->waitFor ('#hello ' );
43
+ $ this ->assertInstanceOf (RemoteWebElement::class, $ c );
44
+ $ this ->assertSame ('Hello ' , $ crawler ->filter ('#hello ' )->text ());
45
+ }
46
+
37
47
/**
38
48
* @dataProvider clientFactoryProvider
39
49
*/
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < title > WaitFor</ title >
6
+ </ head >
7
+ < body >
8
+ < div id ="root "> </ div >
9
+
10
+ < template id ="t-hello ">
11
+ < p id ="hello "> Hello</ p >
12
+ </ template >
13
+
14
+ < script >
15
+ window . setTimeout ( function ( ) {
16
+ document . getElementById ( 'root' ) . appendChild (
17
+ document . importNode ( document . getElementById ( 't-hello' ) . content , true )
18
+ ) ;
19
+ } , 1000 ) ;
20
+ </ script >
21
+ </ body >
22
+ </ html >
You can’t perform that action at this time.
0 commit comments