driver.close()方法在Firefox上的Selenium WebDriver中不起作用 [英] driver.close() method is not working in Selenium WebDriver on Firefox

查看:345
本文介绍了driver.close()方法在Firefox上的Selenium WebDriver中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JUnit注释在Eclipse中编写一个简单程序.

I am writing a simple program in Eclipse using JUnit annotation.

diver.close()没有关闭我的Firefox浏览器. Chrome可以正常使用.代码段在这里.

diver.close() is not closing my Firefox browser after the tests. It works fine with Chrome. Code snippet is here.

public class FireFox1 {
    WebDriver driver;

    @Before
    public void setUp() {
        driver= new FirefoxDriver();
        driver.get("http://book.theautomatedtester.co.uk/chapter4");
    }

    @After
    public void tearDown() {
        driver.close();
    }

    @Test
    public void testExamples() {
        WebElement element= driver.findElement(By.id("nextBid"));
        element.sendKeys("100");     

    }
} 

推荐答案

有时,在重复使用时,我们会遇到driver.close()的问题. 无论如何,driver.quit()将纠正您的问题.

sometimes while on repeated usages,we'll facing problems with driver.close(). Anyways driver.quit() will rectify your problem.

通常driver.close()关闭浏览器(驱动程序实例仍然完好无损),而driver.quit()则杀死webdriver实例.无论如何,您只在这里使用一页,然后就可以使用driver.quit().

Generally driver.close() closes the browser(the instance of driver is still intact) and driver.quit() is to kill the webdriver instance. As anyhow you are using here for only one page,then you can go with driver.quit().

谢谢.

这篇关于driver.close()方法在Firefox上的Selenium WebDriver中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆