当前位置: 首页>>代码示例>>Java>>正文


Java WebDriver.quit方法代码示例

本文整理汇总了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();
}
 
开发者ID:robevansuk,项目名称:delay-repay-bot,代码行数:23,代码来源:PhantomJSTest.java

示例2: htmlUnit

import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
@Test
public void htmlUnit()
{
	WebDriver driver = new HtmlUnitDriver();
	driver.get("http://surenpi.com");
	driver.quit();
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:8,代码来源:DriverTest.java

示例3: clear

import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
/**
 * Clear loaded drivers
 */
public void clear() {
    for (final WebDriver wd : drivers.values()) {
        wd.quit();
    }
    drivers.clear();
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:10,代码来源:DriverFactory.java

示例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();
}
 
开发者ID:MicroFocus,项目名称:SilkAppDriver,代码行数:38,代码来源:MobileTests.java

示例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();
    }
}
 
开发者ID:webrtc,项目名称:KITE,代码行数:10,代码来源:NoAdapterTestTest.java

示例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);
    }
}
 
开发者ID:webrtc,项目名称:KITE,代码行数:18,代码来源:TestManager.java

示例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();
        }
}
 
开发者ID:webrtc,项目名称:KITE,代码行数:10,代码来源:JitsiTestTest.java

示例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();
}
 
开发者ID:Arquisoft,项目名称:dashboard1b,代码行数:10,代码来源:SeleniumUtils.java

示例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
            }
        }


    }
 
开发者ID:italia,项目名称:daf-cacher,代码行数:41,代码来源:ApiService.java

示例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;
			}
		}
	}
}
 
开发者ID:xbynet,项目名称:crawler,代码行数:29,代码来源:PhantomjsWebDriverPool.java

示例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();

}
 
开发者ID:eviltester,项目名称:libraryexamples,代码行数:18,代码来源:SwapiGUIFormUsageTest.java

示例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();
}
 
开发者ID:mluukkai,项目名称:ohjelmistotuotanto2017,代码行数:26,代码来源:Tester.java

示例13: close

import org.openqa.selenium.WebDriver; //导入方法依赖的package包/类
public void close(WebDriver webDriver) {
	refCount.decrementAndGet();
	webDriver.quit();
	webDriver = null;
}
 
开发者ID:xbynet,项目名称:crawler,代码行数:6,代码来源:PhantomjsWebDriverPool.java


注:本文中的org.openqa.selenium.WebDriver.quit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。