當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。