Java tutorial
/** * Copyright 2009-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.javacrumb.webview.webdriver; import net.javacrumbs.webview.driver.WebViewDriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; public class SimpleTest { public static void main(String[] args) throws InterruptedException { // Create a new instance of the html unit driver // Notice that the remainder of the code relies on the interface, // not the implementation. // WebDriver driver = new FirefoxDriver(); WebDriver driver = new WebViewDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // // // Check the title of the page // System.out.println("Page title is: " + driver.getTitle()); // // driver.quit(); } }