本文整理匯總了Java中org.openqa.selenium.remote.RemoteWebDriver.quit方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteWebDriver.quit方法的具體用法?Java RemoteWebDriver.quit怎麽用?Java RemoteWebDriver.quit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openqa.selenium.remote.RemoteWebDriver
的用法示例。
在下文中一共展示了RemoteWebDriver.quit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.openqa.selenium.remote.RemoteWebDriver; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// Create a DesiredCapabilities object to request specific devices from the WebDriver server.
// A udid can be optionally specified, otherwise an arbitrary device is chosen.
DesiredCapabilities caps = new DesiredCapabilities();
// caps.setCapability("uuid", udid);
// Start a WebDriver session. The local machine has to be running the SafariDriverServer, or
// change localhost below to an IP running the SafariDriverServer.
driver = new RemoteWebDriver(new URL("http://localhost:5555/wd/hub"), caps);
// Connect to a URL
driver.get("http://www.google.com");
// Interact with the web page. In this example use case, the Webdriver API is used to find
// specific elements, test a google search and take a screenshot.
driver.findElement(By.id("hplogo"));
// Google New York
WebElement mobileSearchBox = driver.findElement(By.id("lst-ib"));
mobileSearchBox.sendKeys("New York");
WebElement searchBox;
try {
searchBox = driver.findElement(By.id("tsbb"));
} catch (NoSuchElementException e) {
searchBox = driver.findElement(By.name("btnG"));
}
searchBox.click();
takeScreenshot();
driver.navigate().refresh();
takeScreenshot();
// Quit the WebDriver instance on completion of the test.
driver.quit();
driver = null;
}