-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Xpath In WebDriver
At a high level, WebDriver uses a browser's native XPath capabilities wherever possible. On those browsers that don't have native XPath support, we have provided our own implementation. This can lead to some unexpected behaviour unless you are aware of the differences in the various xpath engines.
Driver | Tag and Attribute Names | Attribute Values | Native XPath Support |
---|---|---|---|
HtmlUnitDriver | Lower-cased | As they appear in the HTML | Yes |
InternetExplorerDriver | Lower-cased | As they appear in the HTML | No |
FirefoxDriver | Case insensitive | As they appear in the HTML | Yes |
This is a little abstract, so for the following piece of HTML:
<input type="text" name="example" />
<INPUT type="text" name="other" />
The following will happen:
XPath expression | Number of Matches In | ||
---|---|---|---|
HtmlUnitDriver | FirefoxDriver | InternetExplorerDriver | |
//input | 1 ("example") | 2 | 2 |
//INPUT | 0 | 2 | 0 |
Sometimes HTML do not need attributes to be explicitly declared because they will default to known values. For example, the "input" tag does not require the "type" attribute because it defaults to "text". The rule of thumb when using xpath in WebDriver is that you should not expect to be able to match against these implicit attributes.
This wiki is not where you want to be! Visit the Wiki Home for more useful links
Getting Involved
Build Instructions
Releasing Selenium
Updating Chromium DevTools
Ruby Development
Python Bindings
Ruby Bindings
WebDriverJs
This content is being evaluated for where it belongs
Architectural Overview
Automation Atoms
HtmlUnitDriver
Lift Style API
LoadableComponent
Logging
PageFactory
RemoteWebDriver
Xpath In WebDriver
Moved to Official Documentation
Bot Style Tests
Buck
Continuous Integration
Crazy Fun Build
Design Patterns
Desired Capabilities
Developer Tips
Domain Driven Design
Firefox Driver
Firefox Driver Internals
Focus Stealing On Linux
Frequently Asked Questions
Google Summer Of Code
Grid Platforms
History
Internet Explorer Driver
InternetExplorerDriver Internals
Next Steps
PageObjects
RemoteWebDriverServer
Roadmap
Scaling WebDriver
SeIDE Release Notes
Selenium Emulation
Selenium Grid 4
Selenium Help
Shipping Selenium 3
The Team
TLC Meetings
Untrusted SSL Certificates
WebDriver For Mobile Browsers
Writing New Drivers