File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ // An example of using php-webdriver.
3+
4+ require_once ('lib/__init__.php ' );
5+
6+ // start Firefox
7+ $ host = 'http://localhost:4444/wd/hub ' ; // this is the default
8+ $ capabilities = array (WebDriverCapabilityType::BROWSER_NAME => 'firefox ' );
9+ $ driver = new RemoteWebDriver ($ host , $ capabilities );
10+
11+ // navigate to 'http://docs.seleniumhq.org/'
12+ $ driver ->get ('http://docs.seleniumhq.org/ ' );
13+
14+ // click the link 'About'
15+ $ link = $ driver ->findElement (
16+ WebDriverBy::id ('menu_about ' )
17+ );
18+ $ link ->click ();
19+
20+ // print the title of the current page
21+ echo "The title is " . $ driver ->getTitle () . "' \n" ;
22+
23+ // print the title of the current page
24+ echo "The current URI is " . $ driver ->getCurrentURL () . "' \n" ;
25+
26+ // Search 'php' in the search box
27+ $ input = $ driver ->findElement (
28+ WebDriverBy::id ('q ' )
29+ );
30+ $ input ->sendKeys ('php ' )->submit ();
31+
32+ // wait at most 10 seconds until at least one result is shown
33+ $ driver ->wait (10 )->until (
34+ WebDriverExpectedCondition::presenceOfAllElementsLocatedBy (
35+ WebDriverBy::className ('gsc-result ' )
36+ )
37+ );
38+
39+ // close the Firefox
40+ $ driver ->quit ();
You can’t perform that action at this time.
0 commit comments