我正在尝试在Safari上运行我的Selenium测试。我可以在FireFox和IE上运行我的测试,它运行良好,但在Safari上不行。所以可能有人遇到了同样的问题,可以告诉我为什么它不起作用,是的,我已经将WebDriver添加到SafariExtencions:http://prntscr.com/809miw
我有这个错误:
2015-08-03 13:18:57.666:INFO::main: Logging initialized @169ms
[2015/08/03 13:18:57] [ID:69E814D] [Session Start]: Initializing Session...
[2015/08/03 13:18:58] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:58 PM org.openqa.selenium.safari.SafariDriverServer start
INFO: Server started on port 39280
[2015/08/03 13:18:58] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:58 PM org.openqa.selenium.safari.SafariDriverCommandExecutor start
INFO: Launching Safari
[2015/08/03 13:18:58] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:58 PM org.openqa.selenium.safari.SafariDriverCommandExecutor start
INFO: Waiting for SafariDriver to connect
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:59 PM org.openqa.selenium.safari.SafariDriverChannelHandler$1 operationComplete
INFO: Connection opened
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:59 PM org.openqa.selenium.safari.SafariDriverCommandExecutor start
INFO: Driver connected in 980 ms
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:59 PM org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Shutting down
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:59 PM org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Closing connection
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:59 PM org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Stopping Safari
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:59 PM org.openqa.selenium.os.UnixProcess$SeleniumWatchDog destroyHarder
INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@2038ae61
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:59 PM org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Stopping server
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:59 PM org.openqa.selenium.safari.SafariDriverServer stop
INFO: Stopping server
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Aug 03, 2015 1:18:59 PM org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Shutdown complete
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Exception in thread "main"
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
System info: host: 'Vitaliii-PC', ip: '169.254.8.187', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_45'
Driver info: driver.version: SafariDriver
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:141)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:58)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:51)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at Kodak.AutoTest.Framework.Session.Start(Session.java:117)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at Kodak.AutoTest.QBT.TC93CreateProject.main(TC93CreateProject.java:27)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: Caused by: java.lang.ClassCastException: com.google.gson.JsonObject cannot be cast to java.lang.String
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:111)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:42)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.safari.SafariDriverCommandExecutor.execute(SafariDriverCommandExecutor.java:191)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:578)
[2015/08/03 13:18:59] [ID:69E814D] [Selenium]: ... 7 more
以下是我选择浏览器的方式:
switch(this.type)
{
case IE:
File file = new File(this.config().getParam(ConfigFacade.IEDriverPath_Key));
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
//System.setProperty("webdriver.ie.logfile, ""); // TODO: here somehow redirect log to stream.
this.driver = new InternetExplorerDriver();
break;
case Chrome:
File chromeFile = new File(this.config().getParam(ConfigFacade.ChromeDriverPath_Key));
System.setProperty("webdriver.chrome.driver", chromeFile.getAbsolutePath());
this.driver = new ChromeDriver();
break;
case FireFox:
this.driver = new FirefoxDriver();
break;
case Safari:
this.driver = new SafariDriver();
break;
default:
throw new TestException(String.format("Browser (%1s) is not implemented yet", this.type.toString()));
}
SafariDriver仅适用于OS X。从您的日志中可以看出,您正在尝试在Windows 7上执行它。您可以在此处查看支持的操作系统和浏览器:http://docs.seleniumhq.org/about/platforms.jsp
我正在尝试使用Selenium Grid运行一个简单的程序(事先不了解Selenium Grid),出现如下错误: 线程“main”org.openqa.selenium.remote中出现异常。UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。构建信息:版本:“未知”,版本:“未知”,时间:“未知”系统信息:主机:“DEL1-
我是硒的新手。能够在Ubuntu上配置selenium设置。配置详情如下: 谷歌浏览器68.0.3440.84 但每次跑步我都会发现詹金斯的错误: 请推荐我。
我是硒的新手。尝试以下代码,它适用于Firefox。当我尝试Safari时,出现错误。 硒Safari 任何指针如何解决此问题。
后我Chrome版本更新到96.0.4664.55我不能运行我的硒脚本和得到以下错误 我正在使用WebDriverManager。chromedriver()。设置(); 我看到chromedriver的版本是45,我的浏览器是96.0.4664.55。这是导致此问题的原因吗。我试图搜索55版本的驱动程序,但找不到https://chromedriver.chromium.org/download
我对Selenium是新手,我用Python编程了一个基本的机器人来玩。第一行代码刚刚启动web浏览器: 它工作正常,允许我完成和测试机器人的其余部分,该部分登录帐户并下载文档。 然后我换成了Java(我需要的最后一种语言),并重复了编程,结果非常简单。初始命令为: 代码对于IDE(Intellij)来说很好,但在执行时会出现错误 在端口51171上启动ChromeDriver 98.0.4758
在使用docker-compose在网格上动态执行我的套件时,我得到了以下异常stacktrac: 这是在执行以下操作时发生的: chrome也是如此。我最近将selenium升级到最新版本,即3.141.59。 是: 这在Jenkins和我从cmd在我的系统中执行时都发生了。我不确定这个问题是与selenium还是网络有关。如果有其他解决方案的链接,请在此分享。预先感谢任何帮助。 更新和编辑: