forked from php-webdriver/php-webdriver
-
Notifications
You must be signed in to change notification settings - Fork 55
Selectors
martin-naumann edited this page Jun 15, 2012
·
1 revision
When you need to obtain elements (reads "nearly always") you have a range of different ways to do it, each is called a "Selector". The Selenium-Reference lists the the following available selectors:
- id ("id")
- name ("name")
- css ("css selector")
- XPath ("xpath")
- Link text ("link text")
DOM however seems not to work.
In addition there seem to be a few more (see here):
- class ("class name")
- HTML-Tag ("tag name") - e.g. to find the element
- Part of the link text ("partial link text")
The text in parenthesis is, how they are addressed through the WebDriver interface. An example of "click the link with the text 'click me'" could look like this:
$driver = new WebDriver($url); $session = $driver->session('firefox'); $session->open('http://www.example.org'); $session->element('link text', 'click me')->click();