FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-webdriver/example.php at master · bbc/php-webdriver · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
bbc
/
php-webdriver
Public
forked from
jameshd/php-webdriver
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
php-webdriver
/
example.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (39 loc) · 1.24 KB
Breadcrumbs
php-webdriver
/
example.php
Copy path
File metadata and controls
49 lines (39 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// An example of using php-webdriver.
require_once
(
'
lib/__init__.php
'
);
// start Firefox with 5 second timeout
$
host
=
'
http://localhost:4444/wd/hub
'
;
// this is the default
$
capabilities
= DesiredCapabilities::
firefox
();
$
driver
= RemoteWebDriver::
create
(
$
host
,
$
capabilities
,
5000
);
// navigate to 'http://docs.seleniumhq.org/'
$
driver
->
get
(
'
http://docs.seleniumhq.org/
'
);
// adding cookie
$
driver
->
manage
()->
deleteAllCookies
();
$
driver
->
manage
()->
addCookie
(
array
(
'
name
'
=>
'
cookie_name
'
,
'
value
'
=>
'
cookie_value
'
,
));
$
cookies
=
$
driver
->
manage
()->
getCookies
();
print_r
(
$
cookies
);
// click the link 'About'
$
link
=
$
driver
->
findElement
(
WebDriverBy::
id
(
'
menu_about
'
)
);
$
link
->
click
();
// print the title of the current page
echo
"
The title is
"
.
$
driver
->
getTitle
() .
"
'
\n"
;
// print the title of the current page
echo
"
The current URI is
"
.
$
driver
->
getCurrentURL
() .
"
'
\n"
;
// Search 'php' in the search box
$
input
=
$
driver
->
findElement
(
WebDriverBy::
id
(
'
q
'
)
);
$
input
->
sendKeys
(
'
php
'
)->
submit
();
// wait at most 10 seconds until at least one result is shown
$
driver
->
wait
(
10
)->
until
(
WebDriverExpectedCondition::
presenceOfAllElementsLocatedBy
(
WebDriverBy::
className
(
'
gsc-result
'
)
)
);
// close the Firefox
$
driver
->
quit
();
Back
|
FazBrowse Home
|
New Git URL