本文档用于记录在使用Selenium做自动化测试时遇到的一些问题及可行(可能)的解决方法:
Exception[2017/9/25]:org.openqa.selenium.SessionNotCreatedException
Solution:检查GeckoDriver的路径设置,是否正确启动。
Exception[2017/9/25]:ElementNotInteractableException
click some element not work - 某些元素的点击操作不好用。
1.使用Action click
Actions actions = new Actions(driver);
actions.moveToElement(element).click().build().perform();
2.使用JS click
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].click();", element);
Exception[2017/9/30]:WebDriverException: Reached error page: about:neterror dnsNotFound
因为网站引用了youtube.com上面的内容,无法访问。所以,报了dns错误。
Issue[2017/9/25]:Stop Firefox crash report dialog - 停止Firefox弹出crash report窗口
work around: Turn Off the Error Dialog Through The Group Policy Editor
https://www.raymond.cc/blog/disable-program-has-stopped-working-error-dialog-in-windows-server-2008/
Firefox properties settingnot work, but can read.there:
https://developer.mozilla.org/en-US/docs/Environment_variables_affecting_crash_reporting
Issue[2017/9/25]:OFF GeckoDriver log - 关掉GeckoDriver Log
为GeckoDriver设置启动参数:
ECHO Starting geckodriver: %0 %*
%cd%\BrowserDrivers\geckodriver-v0.18.0-win64\geckodriver.exe --log fatal %* > NUL 2>&1
Issue[2017/9/25]:driver.manage().window().maximize();not work well
在Selenium3.5.3中,该方法没有判断当前窗口的大小,只是点击了最大化按钮。可能是个Bug
Issue[2017/9/25]:JavascriptLibrary:
com.thoughtworks.selenium.webdriven.JavascriptLibrary
该方法已经从jar文件中删除。