【发布时间】:2019-06-25 01:13:54
【问题描述】:
我正在尝试使用 Selenium Grid 在 MacOS 上启动 Safari 进行基本测试。
我已经注册了节点,它在我的集线器中显示如下。
- 浏览器超时:0
- 调试:错误
- 主机:10.120.45.211
- 端口:5558
- 角色:节点
- 超时:1800
- cleanUpCycle: 5000
- 最大会话:5
- 功能:功能 {browserName:Safari,maxInstances:1, 平台:MAC,平台名称:MAC,seleniumProtocol:WebDriver, 服务器:CONFIG_UUID:1ba7b7b4-556c-430a-ab84-157...}
- downPollingLimit: 2
- 集线器:http://10.120.45.245:4444/grid/register
- 身份证号:http://10.120.45.211:5558
- 节点轮询:5000
- nodeStatusCheckTimeout: 5000
- 代理:org.openqa.grid.selenium.proxy.DefaultRemoteProxy
- 注册:真
- 注册周期:5000
- 远程主机:http://10.120.45.211:5558
- 注销IfStillDownAfter:60000
我了解 SafariDriver 现在可以直接在 macOS 中使用,我正在使用这些步骤来确保其设置正确。
如果您还没有这样做,请打开“开发”菜单。选择 Safari > 首选项,然后在“高级”选项卡上,选择“在菜单栏中显示开发菜单”。有关详细信息,请参阅 Safari 帮助。 选择“开发”>“允许远程自动化”。 授权 safaridriver 启动托管本地 Web 服务器的 XPC 服务。为此,请手动运行 /usr/bin/safaridriver 一次并按照身份验证提示进行操作。
这是我的 JAVA 代码:
package SeleniumGrid;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class SafariRemoteAccess {
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities dc = new DesiredCapabilities();
dc.setBrowserName("Safari");
//Point to hub
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc);
// Go to website via NODE
driver.get("https://www.hsbc.co.uk/");
driver.quit();
}
}
当我运行程序时,我收到以下消息。
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create session from {
"desiredCapabilities": {
"browserName": "Safari",
"server:CONFIG_UUID": "1ba7b7b4-556c-430a-ab84-1574fc7ea584"
},
"capabilities": {
"firstMatch": [
{
"browserName": "Safari",
"server:CONFIG_UUID": "1ba7b7b4-556c-430a-ab84-1574fc7ea584"
}
]
}
}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'Mishal-Shahs-MacBook-Pro.local', ip: 'fe80:0:0:0:c9b:214f:9f0:2788%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.2', java.version: '1.8.0_202'
Driver info: driver.version: unknown
Command duration or timeout: 198 milliseconds**
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$errorHandler$0(JsonWireProtocolResponse.java:54)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at SeleniumGrid.SafariRemoteAccess.main(SafariRemoteAccess.java:17)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create session from {
"desiredCapabilities": {
"browserName": "Safari",
"server:CONFIG_UUID": "1ba7b7b4-556c-430a-ab84-1574fc7ea584"
},
"capabilities": {
"firstMatch": [
{
"browserName": "Safari",
"server:CONFIG_UUID": "1ba7b7b4-556c-430a-ab84-1574fc7ea584"
}
]
}
}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'Mishal-Shahs-MacBook-Pro.local', ip: 'fe80:0:0:0:c9b:214f:9f0:2788%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.2', java.version: '1.8.0_202'
Driver info: driver.version: unknown
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'LAPTOP-1MOS5JFR', ip: '10.120.45.245', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_192'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null$4(NewSessionPipeline.java:76)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$5(NewSessionPipeline.java:75)
at java.util.Optional.orElseGet(Optional.java:267)
at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession(NewSessionPipeline.java:73)
at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute(BeginSession.java:65)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:235)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
更新
这是我用来在 MacOS 机器上设置节点的代码:
java -Dwebdriver.safari.driver=/System/Library/CoreServices/SafariSupport.bundle/Contents/MacOS/safaridriver.exe -jar selenium-server-standalone-3.141.59.jar -role node -hub 10.120.45.245:4444/grid/register -port 5558 -browser "browserName=Safari, platform=MAC, platformName=MAC, maxInstances=1"
【问题讨论】:
标签: java selenium selenium-webdriver selenium-grid safaridriver