org.openqa.selenium.SessionNotCreatedException:找到了一些设备,但无法使用。远程自动化已关闭

问题描述 投票:0回答:0

我使用 MacOS 主机在真实的 iOS 设备上自动化 safari。报如下错误:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not create a session: Some devices were found, but could not be used:
- iPhone : Remote Automation is turned off (turn it on via Settings > Safari > Advanced > Remote Automation)
Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: '2019-07-01T21:30:18'
System info: host: 'MacBook-Pro.local', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_271'
Driver info: driver.version: SafariDriver
remote stacktrace: 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
    at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$1(ProtocolHandshake.java:127)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:129)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:139)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:576)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:210)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
    at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:81)
    at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:63)
    at com.chomedriver.IOSSafariTest.getDriver(IOSSafariTest.java:22)
    at com.chomedriver.IOSSafariTest.main(IOSSafariTest.java:45)

但我已经开启了远程自动化。 这是我的程序:

public class IOSWebView {
    public static RemoteWebDriver getDriver() {
        SafariOptions safariOptions = new SafariOptions();
        safariOptions.setCapability("platformName", "ios");
        return new SafariDriver(safariOptions);
    }

    public static void main(String[] args) {
        RemoteWebDriver driver = getDriver();
        driver.get("https://www.qq.com");
        System.out.println(driver.getCurrentUrl());
        System.out.println(driver.getTitle());
        driver.quit();
    }
}

我的MacOS版本是11.6,iOS版本是16.3.1。 请帮帮我~

我已经在我的电脑上更新了safaridriver,但是还是不行。

selenium-webdriver mobile-safari safaridriver
© www.soinside.com 2019 - 2024. All rights reserved.