Selenium3+MoocTest环境搭建常见问题解决方案
官方文檔:http://mooctest-site.oss-cn-shanghai.aliyuncs.com/guide/Web%E5%BA%94%E7%94%A8%E6%B5%8B%E8%AF%95%E6%8C%87%E5%8D%97.pdf
筆者使用Chrome瀏覽器
Java環境
配置ChromeDriver
官網:https://sites.google.com/a/chromium.org/chromedriver/home
淘寶:https://npm.taobao.org/mirrors/chromedriver
需要對應Chrome版本
以下配置相同效果
Unable to create new remote session.
Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}) on port 37478
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, chromeOptions=org.openqa.selenium.chrome.ChromeOptions@1b550c0, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: ‘3.3.0’, revision: ‘b526bd5’, time: ‘2017-03-07 11:21:31 -0800’
System info: host: ‘ALEXMSI’, ip: ‘192.168.137.1’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘13-ea’
Driver info: driver.version: ChromeDriver
解決:mooctest工具下載頁面的selenium是3.3.0版本,可能不能匹配Chrome瀏覽器需要下文檔中的3.9.1版本
The path to the driver executable must be set by the webdriver.chrome.driver system property;
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
解決:
注意:將chromedriver.exe的路徑添加到環境變量,添加之后需要重啟eclipse
unknown error: cannot find Chrome binary
本地不可以運行
是否將webdriver和Chrome添加到Path
本地可以運行,提交不行
是否采用
根據
估計提交測試時不會運行main函數。
解決:需要設置環境變量
沒有運行日志,成績為0
不要修改示例代碼結構。
如果Selenium插件導出的是Junit版本,需要手動修改去除Junit內容。
無法加載主類
一般是少了jar包
解決: 在C盤下的MOOCTEST文件加下面放一個 selenium-standalone.jar 不論下載的那個版本改成這樣的名字
最新的Chrome瀏覽器版本太高
解決: 卸載了 連帶注冊表 我用的IObit Uninstaller卸載了 電腦管家的也可以下載一個低版本 74 的就可以, 驅動大版本也要對應就可以了
參考文章
Selenium3+java1.0.8_271 MoocTest環境搭建遇到的問題
selenium + WebDriver + java啟動瀏覽器報錯
selenium無法正常運行 Chrome瀏覽器,cannot find Chrome binary的問題
總結
以上是生活随笔為你收集整理的Selenium3+MoocTest环境搭建常见问题解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 功能测试——医疗管理系统
- 下一篇: 性能测试——美团国内机票网站(Badbo