本文整理汇总了Java中org.openqa.selenium.WebDriver.quit方法的典型用法代码示例。如果您正苦于以下问题:Java WebDriver.quit方法的具体用法?Java WebDriver.quit怎么用?Java WebDriver.quit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.WebDriver
的用法示例。
在下文中一共展示了WebDriver.quit方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDriver
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
@Test
public void testDriver() throws IOException {
WebDriver driver = new RemoteWebDriver(toUrl("http://localhost:9515"), DesiredCapabilities.chrome());
driver.get(URL2);
String response = driver.getPageSource();
Document doc = Jsoup.connect(URL2).ignoreContentType(true).get();
Elements scriptTags = doc.select("body");
// get All functions
try {
String result = (String) engine.eval(response);
} catch (ScriptException e) {
e.printStackTrace();
}
log.info("PageSource " + response);
driver.quit();
}
示例2: htmlUnit
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
@Test
public void htmlUnit()
{
WebDriver driver = new HtmlUnitDriver();
driver.get("http://surenpi.com");
driver.quit();
}
示例3: clear
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
/**
* Clear loaded drivers
*/
public void clear() {
for (final WebDriver wd : drivers.values()) {
wd.quit();
}
drivers.clear();
}
示例4: test
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
@Ignore
@Test
public void test() throws IOException {
Map<String, String> baseState = new HashMap<>();
baseState.put("type", "MOBILE");
baseState.put("connectionString", "platformName=Android;app=C:\\apps\\InsuranceMobile.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appdriver-basestate", baseState);
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:8080"), capabilities);
String title = driver.getTitle();
assertEquals("", title); // TODO: Maybe we find something to use as the
// title?
WebElement email = driver
.findElement(By.xpath("//MobileTextField[@resource-id='silktest.insurancemobile:id/email']"));
email.sendKeys("test");
assertEquals("test", email.getText());
email.clear();
assertEquals("", email.getText());
email.sendKeys("[email protected]");
driver.findElement(By.xpath("//MobileTextField[@resource-id='silktest.insurancemobile:id/password']"))
.sendKeys("john");
driver.findElement(By.xpath("//MobileButton[@resource-id='silktest.insurancemobile:id/log_in_button']"))
.click();
driver.findElement(By.xpath("//MobileObject[@content-desc='drawer_open']")).click();
driver.findElement(By.xpath("//MobileObject[@caption='Logout']")).click();
driver.quit();
}
示例5: tearDown
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
public void tearDown() throws Exception {
// Close all the browsers
for (WebDriver webDriver : this.webDriverList)
try {
webDriver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: closeDrivers
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
/**
* Quits all of the web drivers in the list.
*/
private void closeDrivers() {
for (WebDriver webDriver : this.webDriverList)
try {
// Open about:config in case of fennec (Firefox for Android) and close.
if (((RemoteWebDriver) webDriver).getCapabilities().getBrowserName().equalsIgnoreCase("fennec")) {
webDriver.get("about:config");
webDriver.close();
} else {
webDriver.quit();
}
} catch (Exception e) {
logger.error("closing driver:", e);
}
}
示例7: tearDown
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
public void tearDown() throws Exception {
// Close all the browsers
for (WebDriver webDriver : this.webDriverList)
try {
webDriver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
示例8: finishTest
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
public static void finishTest(WebDriver driver){
if (System.getenv().get("TRAVIS_JOB_NUMBER") != null) {
SauceREST sauceRest = new SauceREST(System.getenv().get("SAUCE_USERNAME"), System.getenv().get("SAUCE_ACCESS_KEY"));
sauceRest.jobPassed((((RemoteWebDriver) driver).getSessionId()).toString());
}
driver.close();
driver.quit();
}
示例9: handleNewSnap
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
private byte[] handleNewSnap(final String id, final String size) throws IOException, TimeoutException {
final EmbeddableData data = getAvailablePlotList()
.stream()
.filter(x -> x.getIdentifier().equals(id))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("The request " + id + " is not available"));
final WebDriver webDriver = webDriver();
try (Jedis jedis = jedisPool.getResource()) {
final Page pageHandler = fromId(id);
final ScreenShotService.Builder builder = new ScreenShotService
.Builder()
.setPageHandler(pageHandler)
.jedis(jedis)
.id(id)
.webDriver(webDriver)
.plotUrl(new URL(data.getIframeUrl()))
.ttl(Integer.parseInt(properties.getProperty("caching.ttl")))
.timeout(30);
if (!size.equals(ORIGINAL_SIZE))
builder.geometry(Geometry.fromString(size));
final ScreenShotService service = builder.build();
service.perform();
return service.fetch(id, size);
} finally {
try {
if (webDriver != null) {
webDriver.close();
webDriver.quit();
}
} catch (Exception ex) {
//Ignored
}
}
}
示例10: returnToPool
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
public void returnToPool(WebDriver webDriver) {
if (shutdowned.get()) {
webDriver.quit();
webDriver = null;
} else {
Set<String> handles = webDriver.getWindowHandles();
if (handles.size() > 1) {
int index = 0;
for (String handle : handles) {
if (index == 0) {
index++;
continue;
}
WindowUtil.changeWindowTo(webDriver, handle);
webDriver.close();
index++;
}
}
synchronized (shutdowned) {
if(!shutdowned.get()){
innerQueue.add(webDriver);
}else{
webDriver.quit();
webDriver = null;
}
}
}
}
示例11: canGetSwapiGUIPage
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
@Test
public void canGetSwapiGUIPage(){
//WebDriver driver = new HtmlUnitDriver(BrowserVersion.BEST_SUPPORTED, true);
WebDriver driver = new ChromeDriver();
// On mac SafariDriver is built in
// driver = new SafariDriver();
driver.get("https://swapi.co/");
Assert.assertTrue(driver.getTitle().contains("Star Wars"));
driver.quit();
}
示例12: main
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("http://localhost:4567");
sleep(2);
WebElement element = driver.findElement(By.linkText("login"));
element.click();
sleep(2);
element = driver.findElement(By.name("username"));
element.sendKeys("pekka");
element = driver.findElement(By.name("password"));
element.sendKeys("akkep");
element = driver.findElement(By.name("login"));
sleep(2);
element.submit();
sleep(3);
driver.quit();
}
示例13: close
import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
public void close(WebDriver webDriver) {
refCount.decrementAndGet();
webDriver.quit();
webDriver = null;
}