简体   繁体   English

Selenium Edge WebDriver (Chromium) - session 未创建:未找到匹配功能

[英]Selenium Edge WebDriver (Chromium) - session not created: No matching capabilities found

I'm trying to run a Selenium test with Java and Edge driver (based on Chromium).我正在尝试使用 Java 和 Edge 驱动程序(基于 Chromium)运行 Selenium 测试。

The version of my Edge Dev installed on Windows 10 is 83.0.478.37 (Official build dev 64-bit):我在Windows 10上安装的 Edge Dev 的版本是83.0.478.37 (官方构建开发 64 位):

Selenium Version: 3.141.59 Selenium 版本: 3.141.59

I'm using webdrivermanager setup for this and used the example provided here .我为此使用了 webdrivermanager 设置,并使用了此处提供的示例。

I tried many options it includes without using webdriver manager but still gives the error.我在不使用 webdriver manager 的情况下尝试了它包含的许多选项,但仍然出现错误。

Without Using Webdriver Manager不使用 Webdriver 管理器

System.setProperty("webdriver.edge.driver", System.getProperty("user.dir")
                            + "\\drivers\\msedgedriver.exe");

EdgeOptions edgeOptions = new EdgeOptions();

chromeOptions = new ChromeOptions();
chromeOptions.addArguments("disable-gpu");
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
edgeOptions = edgeOptions.merge(chromeOptions);

remDriver = new EdgeDriver(edgeOptions);

AND followed other solutions from here这里遵循其他解决方案

Am i missing something?我错过了什么吗?

The error stack trace below -下面的错误堆栈跟踪 -

org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'VM-83135Y0-RDS', ip: '10.232.38.151', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: driver.version: EdgeDriver
remote stacktrace: Backtrace:
    Ordinal0 [0x00007FF7AE6E1BD2+3414994]
    Ordinal0 [0x00007FF7AE5B75B2+2192818]
    Ordinal0 [0x00007FF7AE45477F+739199]
    Ordinal0 [0x00007FF7AE3DF5BF+259519]
    Ordinal0 [0x00007FF7AE3DEEB4+257716]
    Ordinal0 [0x00007FF7AE3E0601+263681]
    Ordinal0 [0x00007FF7AE3DD68F+251535]
    Ordinal0 [0x00007FF7AE3BA663+108131]
    Ordinal0 [0x00007FF7AE3BB9CE+113102]
    Ordinal0 [0x00007FF7AE5D24F1+2303217]
    GetHandleVerifier [0x00007FF7AE85E564+1425828]
    GetHandleVerifier [0x00007FF7AE85E32A+1425258]
    GetHandleVerifier [0x00007FF7AE8762E1+1523489]
    GetHandleVerifier [0x00007FF7AE85EB7B+1427387]
    Ordinal0 [0x00007FF7AE5C8797+2262935]
    Ordinal0 [0x00007FF7AE5D3ECA+2309834]
    Ordinal0 [0x00007FF7AE5F20C8+2433224]
    BaseThreadInitThunk [0x00007FFE43164034+20]
    RtlUserThreadStart [0x00007FFE453A3691+33]

    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$0(ProtocolHandshake.java:126)
    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:498)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    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: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.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    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.edge.EdgeDriver.<init>(EdgeDriver.java:141)
    at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:130)

Try setting DesiredCapability PLATFORM as WINDOWS instead of WIN10:尝试将 DesiredCapability PLATFORM 设置为 WINDOWS 而不是 WIN10:

capabilities.setPlatform(Platform.WINDOWS);能力.setPlatform(平台.WINDOWS);

You can check the platform by using url: http://<NODE_HOST>:<YOUR_DRIVER_PORT>/status您可以使用 url 来检查平台:http://<NODE_HOST>:<YOUR_DRIVER_PORT>/status

replace <NODE_HOST> with your node hostname or ip address and <YOUR_DRIVER_PORT> with port on which driver has been started..将 <NODE_HOST> 替换为您的节点主机名或 ip 地址,将 <YOUR_DRIVER_PORT> 替换为已启动驱动程序的端口。

You can easily get this url from node logs if you start node in debug mode by passing -debug while starting node and then search for line similar to below:如果您在调试模式下通过在启动节点时传递 -debug 来启动节点,然后搜索类似于以下的行,则可以轻松地从节点日志中获取此 url:

DEBUG [UrlChecker.lambda$waitUntilAvailable$1] - Polling http://localhost:48415/status调试 [UrlChecker.lambda$waitUntilAvailable$1] - 轮询 http://localhost:48415/status

http://localhost:48415/status http://localhost:48415/status

{"value":{"build":{"version":"88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784})"},"message":"ChromeDriver ready for new sessions.","os":{"arch":"x86_64","name":"Windows NT","version":"10.0.19041"},"ready":true}} {"value":{"build":{"version":"88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784})"},"message":"ChromeDriver 准备好进行新会话。" ,"os":{"arch":"x86_64","name":"Windows NT","version":"10.0.19041"},"ready":true}}

Even if I am having Windows10 installed, it returns "name":"Windows NT","version":"10.0.19041", hence tried with WINDOWS as platform and it worked perfectly fine!!!即使我安装了 Windows10,它也会返回 "name":"Windows NT","version":"10.0.19041",因此尝试使用 WINDOWS 作为平台,它工作得很好!!!

Fixed it with little tweaks, and used the WebdriverManager .稍作调整就修复了它,并使用了WebdriverManager

Observed an issue with WebdriverManager, it is downloading a different version of edgedriver and eventually it is failing because of the driver/browser incompatibility.观察到 WebdriverManager 的问题,它正在下载不同版本的edgedriver ,最终由于驱动程序/浏览器不兼容而失败。

Check the browser version against the available driver version.根据可用的驱动程序版本检查浏览器版本。 If both are different, set the edge driver version like below.如果两者不同,请设置边缘驱动程序版本,如下所示。

In my scenario - Edge Browser Version is 84.0.522.49 but its downloading 84.0.524.0在我的场景中 - 边缘浏览器版本是84.0.522.49但它的下载84.0.524.0

WebDriverManager manager = WebDriverManager.edgedriver();
manager.config().setEdgeDriverVersion("84.0.522.49");
manager.setup();
EdgeOptions options = new EdgeOptions();
driver = new EdgeDriver(options);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM