本文整理了Java中org.openqa.selenium.WebDriver.quit()
方法的一些代码示例,展示了WebDriver.quit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebDriver.quit()
方法的具体详情如下:
包路径:org.openqa.selenium.WebDriver
类名称:WebDriver
方法名:quit
[英]Quits this driver, closing every associated window.
[中]退出此驱动程序,关闭所有相关窗口。
代码示例来源:origin: stackoverflow.com
driver.quit();
driver.get("http://mypage.com");
代码示例来源:origin: stackoverflow.com
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class Test{
private WebDriver driver;
private String output;
public Document getDocument(String input) {
driver = new HTMLUnitDriver(true); //the param true turns on javascript.
driver.get(input);
output = driver.getPageSource();
driver.quit();
return Jsoup.parse(output);
}
}
代码示例来源:origin: stackoverflow.com
@Test
public void test()
{
WebDriver driver=new FirefoxDriver();
driver.get("http://www.google.com");
System.out.println(driver.getTitle());
driver.quit();
}
代码示例来源:origin: stackoverflow.com
driver.quit();
driver.get("http://mypage.com");
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
File file = new File("C:/Program Files/phantomjs-2.0.0-windows/bin/phantomjs.exe");
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());
WebDriver driver = new PhantomJSDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Guru99");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
代码示例来源:origin: stackoverflow.com
reate 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 HtmlUnitDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
System.out.println( driver.getPageSource());
driver.quit();
}
代码示例来源:origin: appium/java-client
@Test public void chromeTest() {
WebDriver driver = new ChromeDriver();
try {
PageFactory
.initElements(new AppiumFieldDecorator(driver, ofSeconds(15)),
this);
driver.get(new File("src/test/java/io/appium/java_client/hello appium - saved page.htm")
.toURI().toString());
assertNotEquals(0, foundLinks.size());
assertNotEquals(0, main.size());
assertNull(trap1);
assertNull(trap2);
} finally {
driver.quit();
}
}
}
代码示例来源:origin: stackoverflow.com
public void testGoogle() throws Exception {
WebDriver driver = new AndroidDriver();
driver.get("http://www.google.co.in");
Thread.sleep(4000);
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Welcome");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
//System.setProperty("webdriver.chrome.driver", "./chromedriver.exe");
//WebDriver driver = new ChromeDriver();
WebDriver driver = new FirefoxDriver();
driver.get("file:///C:/Users/jgong/Desktop/a.html");
String html = driver.getPageSource();
System.out.println(html);
driver.quit();
Document doc = Jsoup.parse(html);
System.out.println(doc.html());
}
代码示例来源:origin: stackoverflow.com
WebDriver driver = new FirefoxDriver();
driver.get("file://<Path>/div.html");
long starttime = System.currentTimeMillis();
//driver.findElement(By.cssSelector(".class"));
//driver.findElement(By.className("class"));
//driver.findElement(By.cssSelector("#id"));
//driver.findElement(By.id("id"));
//driver.findElement(By.cssSelector("div"));
//driver.findElement(By.tagName("div"));
long stoptime = System.currentTimeMillis();
System.out.println(stoptime-starttime + " milliseconds");
driver.quit();
代码示例来源:origin: selendroid/demoproject-selendroid
@Test
public void shouldSearchWithEbay() {
// And now use this to visit ebay
driver.get("http://m.ebay.de");
// Find the text input element by its id
WebElement element = driver.findElement(By.id("kw"));
// Enter something to search for
element.sendKeys("Nexus 5");
// 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();
}
代码示例来源:origin: stackoverflow.com
WebDriver driver = new FirefoxDriver();
driver.get("file://<Path>/div.html");
long starttime = System.currentTimeMillis();
//driver.findElement(By.className("class"));
//driver.findElement(By.cssSelector("html body div"));
//driver.findElement(By.id("id"));
//driver.findElement(By.name("name"));
//driver.findElement(By.tagName("div"));
//driver.findElement(By.xpath("/html/body/div"));
long stoptime = System.currentTimeMillis();
System.out.println(stoptime-starttime + " milliseconds");
driver.quit();
代码示例来源:origin: stackoverflow.com
public class Wiki
{
@Test
public void createAccount() throws InterruptedException
{
WebDriver driver = new FirefoxDriver();
WebDriverWait wait=new WebDriverWait(driver,60);
driver.get("http://en.wikipedia.org/wiki/Main_Page");
driver.findElement(By.linkText("Create account")).click();
wait.until(ExpectedConditions.titleContains("Create account - Wikipedia, the free encyclopedia"));
Assert.assertEquals("Create account - Wikipedia, the free encyclopedia",driver.getTitle());
driver.quit();
}
}
代码示例来源:origin: stackoverflow.com
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestClass1{
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
driver.quit();
}
}
代码示例来源:origin: stackoverflow.com
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://www.adspapa.com/");
WebElement catBox = driver.findElement(By.xpath("html/body/table[1]/tbody/tr/td/table/tbody/tr/td[1]/table"));
List<WebElement> catValues = catBox.findElements(By.tagName("a"));
for(int i=0;i<catValues.size();i++)
{
catValues.get(i).click();
System.out.println(driver.getTitle());
driver.navigate().back();
catBox = driver.findElement(By.xpath("html/body/table[1]/tbody/tr/td/table/tbody/tr/td[1]/table"));
catValues = catBox.findElements(By.tagName("a"));
}
driver.quit();
代码示例来源:origin: stackoverflow.com
@Test
public void changeExpression() throws Exception {
WebDriver browser = new FirefoxDriver();
browser.get("http://google.com");
WebElement searchBtn =
browser.findElement(By.xpath("*//form//input[@value='Google Search']"));
//do other stuff...
browser.quit();
}
代码示例来源:origin: stackoverflow.com
WebDriver driver = new HtmlUnitDriver();
driver.get("https://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Hello");
driver.quit();
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");
driver.quit();
}
代码示例来源:origin: stackoverflow.com
public class BaseTest{
static WebDriver driver;
@BeforeSuite
public void start() {
driver = new FFDriver();
driver.get(url);
}
@AfterSuite
public void end() {
driver.close();
driver.quit();
}
}
代码示例来源:origin: stackoverflow.com
WebDriver driver = new FirefoxDriver();
driver.get("URL");
//Do some actions
driver.quit();
内容来源于网络,如有侵权,请联系作者删除!