selenium webdriver方法qiut()close()区别
来源:互联网 发布:ubuntu 传输文件 编辑:程序博客网 时间:2024/05/19 12:27
最近在研究chrome headless 版本号59+ 但是selenium的webdriver最新版本最高支持chrome58。
driver.close()调试过程出现bug:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: failed to close window in 20 seconds
(Session info: headless chrome=59.0.3071.86)
(Driver info: chromedriver=2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262),platform=Mac OS X 10.11.6 x86_64)
查询close和qiut 的区别:
This is a good question I have seen people use Close() when they shouldn't. I looked in the source code for the Selenium Client & WebDriver C# Bindings and found the following.
webDriver.Close()
- Close the browser window that the driver has focus ofwebDriver.Quit()
- Calls Dispose()webDriver.Dispose()
Closes all browser windows and safely ends the session
The code below will dispose the driver object, ends the session and closes all browsers opened during a test whether the test fails or passes.
public IWebDriver Driver;[SetUp]public void SetupTest(){ Driver = WebDriverFactory.GetDriver();}[TearDown]public void TearDown(){ if (Driver != null) Driver.Quit();}
In summary ensure that Quit() or Dispose() is called before exiting the program, and don't use the Close() method unless you're sure of what you're doing.
Note
I found this question when try to figure out a related problem why my VM's were running out of harddrive space. Turns out an exception was causing Quit() or Dispose() to not be called every run which then caused the appData folder to fill the hard drive. So we were using the Quit() method correctly but the code was unreachable. Summary make sure all code paths will clean up your unmanaged objects by using exception safe patterns or implement IDisposable
Also
In the case of RemoteDriver calling Quit() or Dispose() will also close the session on the Selenium Server. If the session isn't closed the log files for that session remain in memory.
- selenium webdriver方法qiut()close()区别
- Selenium - Differences between WebDriver.close(), WebDriver.dispose() and WebDriver.quit()
- selenium和webdriver区别
- selenium Webdriver 封装方法
- selenium webdriver 常用方法
- selenium webdriver定位方法
- selenium中的quit和close方法的区别
- selenium webdriver 元素定位方法
- selenium webdriver重写的方法
- Selenium Webdriver元素定位方法
- selenium webdriver 你所不知道的quit 和close
- Selenium里WebDriver中窗口的close()与quit()
- selenium webdriver 你所不知道的quit 和close
- WebDriver api 中close、quit的区别
- 【学习笔记】Selenium WebDriver的Actions类中的sendKeys方法和WebElement.sendKeys方法的区别
- Selenium不同浏览器WebDriver处理方法
- Selenium + Webdriver 学习(四) 元素定位方法
- Selenium + Webdriver 学习(四) 元素定位方法
- 常用平台包名
- 设计模式-状态模式
- codeforces 794G. Replace All
- c++ 为什么析构函数必须声明为虚函数
- ORACLE Hints
- selenium webdriver方法qiut()close()区别
- 乐视断缴社保 乐视负债百亿 钱景堪忧!
- PCB布高速线——需要考虑信号传输延时
- 获取复选框的值
- spring学习笔记一
- xml文件解析的几种方式(一)
- Leetcode 208 Implement Trie (Prefix Tree)
- CSS 实现隐藏滚动条同时又可以滚动
- ResourceBundle