我写了一个基本的脚本,在Firefox中运行,但在Safari上不断破解,我搜索了不同的网站,但找不到有效的答案。请帮忙。
我正在使用Safari - 版本8.0(10600.1.25)
OS X Yosemite - 版本10.10(14A389a)
Selenium - 版本2.46.0
Eclipse - 版本:Mars Release(4.5.0)
Safaridriver - 版本2.45.0
我在浏览器上安装了驱动程序,并手动启用了驱动程序 我正在尝试在本地计算机上运行脚本。
package test;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.safari.SafariDriver;
public class QC {
WebDriver driver;
@Test
public void trail1() {
driver = new SafariDriver();
driver.get("http://yahoo.com/");
driver.quit();
记录
Jul 16, 2015 4:07:51 PM
org.openqa.selenium.safari.SafariDriverServer start
INFO: Server started on port 18465
Jul 16, 2015 4:07:51 PM
org.openqa.selenium.safari.SafariDriverCommandExecutor start
INFO: Launching Safari
Jul 16, 2015 4:07:51 PM
org.openqa.selenium.safari.SafariDriverCommandExecutor start
INFO: Waiting for SafariDriver to connect
Jul 16, 2015 4:07:53 PM
org.openqa.selenium.safari.SafariDriverChannelHandler$1
operationComplete
INFO: Connection opened
Jul 16, 2015 4:07:53 PM
org.openqa.selenium.safari.SafariDriverCommandExecutor start
INFO: Driver connected in 1398 ms
Jul 16, 2015 4:07:53 PM
org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Shutting down
Jul 16, 2015 4:07:53 PM
org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Closing connection
Jul 16, 2015 4:07:53 PM
org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Stopping Safari
Jul 16, 2015 4:07:53 PM
org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Stopping server
Jul 16, 2015 4:07:53 PM org.openqa.selenium.safari.SafariDriverServer
stop
INFO: Stopping server
Jul 16, 2015 4:07:53 PM
org.openqa.selenium.safari.SafariDriverCommandExecutor stop
INFO: Shutdown complete
异常
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:17:10'
System info: host: 'Heathers-MacBook-Pro.local', ip: '10.2.2.60',
os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10',
java.version: '1.7.0_79'
Driver info: driver.version: SafariDriver
at
org.openqa.selenium.remote.RemoteWebDriver.execute
(RemoteWebDriver.java:599)at
org.openqa.selenium.remote.RemoteWebDriver.startSession
(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.<init>
(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>
(RemoteWebDriver.java:141)
at org.openqa.selenium.safari.SafariDriver.<init>
(SafariDriver.java:58)
at org.openqa.selenium.safari.SafariDriver.<init>
(SafariDriver.java:42)
at test.QC.trail1(QC.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall
(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.
run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively
(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate
(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild
(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild
(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.
run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.
run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassCastException:
com.google.gson.JsonObject cannot be cast to java.lang.String
at org.openqa.selenium.remote.JsonToBeanConverter.
convert(JsonToBeanConverter.java:111)
at org.openqa.selenium.remote.JsonToBeanConverter.
convert(JsonToBeanConverter.java:42)
at org.openqa.selenium.safari.SafariDriverCommandExecutor
.execute(SafariDriverCommandExecutor.java:191)
at org.openqa.selenium.remote.RemoteWebDriver
.execute(RemoteWebDriver.java:578)
... 29 more
SafariDriver记录
16:17:14.61 [safaridriver.extension] Creating global session...
16:17:14.61 [safaridriver.extension.TabManager] Registering new tab
16:17:14.61 [safaridriver.extension.TabManager] Set command tab to
udprznycqv1n
16:17:14.61 [safaridriver.extension] Creating debug driver...
16:17:14.61 [safaridriver.extension] Waiting for connect command...
16:17:20.36 [safaridriver.extension.TabManager] Registering new tab
16:17:20.36 [safaridriver.extension.TabManager] Tab opened:
2g26bt5u941a
16:17:20.45 [safaridriver.extension.TabManager] Ignoring open window
event
16:17:20.45 [safaridriver.extension.TabManager] Deleting entry for
tab 2g26bt5u941a
16:17:20.62 [safaridriver.extension.Server] [nsg825n5gk7s] Executing
command: newSession
答案 0 :(得分:0)
仅供参考 - 我降级为Selenium 2.45.0,它现在运行得很好。