Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ubuntu上的Selenium 4、Microsoft Edge(铬)_Selenium_Selenium Webdriver_Selenium4_Microsoft Edge Chromium - Fatal编程技术网

Ubuntu上的Selenium 4、Microsoft Edge(铬)

Ubuntu上的Selenium 4、Microsoft Edge(铬),selenium,selenium-webdriver,selenium4,microsoft-edge-chromium,Selenium,Selenium Webdriver,Selenium4,Microsoft Edge Chromium,我目前正试图让我的自动测试在ubuntu的chromium edge上运行 我当前的设置是: 设置如下: 浏览器位于运行Ubuntu的docker容器中 中心位于Selenium 4 docker官方集装箱上 在运行.Net Core 2.2的单独docker容器上进行测试 RemoteWebDriver注册如下所示 。。。。。 var edgeOptions=新的edgeOptions(); edgeOptions.UseCromium=true; AddUserProfilePrefer

我目前正试图让我的自动测试在ubuntu的chromium edge上运行

我当前的设置是: 设置如下:

  • 浏览器位于运行Ubuntu的docker容器中
  • 中心位于Selenium 4 docker官方集装箱上
  • 在运行.Net Core 2.2的单独docker容器上进行测试
RemoteWebDriver注册如下所示

。。。。。
var edgeOptions=新的edgeOptions();
edgeOptions.UseCromium=true;
AddUserProfilePreference(“download.default_目录”,DownloadFolderPath);
edgeOptions.AddArguments(“--no sandbox”);//绕过操作系统安全模型
edgeOptions.AddArguments(“--忽略证书错误”);//忽略ssl错误
edgeOptions.AddArgument(“--disable dev shm usage”);//忽略shm使用
edgeOptions.AddArguments(“--忽略urlfetcher证书请求”);//忽略url证书请求获取
edgeOptions.AddArguments(“--force devtools available=1”);//忽略url证书请求获取
AddArguments($“--lang={u language}”)//从系统属性中设置浏览器语言。
GetEdgeDriver(建筑商、edgeOptions);
.......
专用void GetEdgeRemoteDriver(ContainerBuilder生成器、EdgeOptions选项)
{
建设者
.Register(=>new RemoteWebDriver(新Uri(RemoteEndPoint),options.ToCapabilities(),TimeSpan.FromMinutes(5)))
.As()
.InstancePerLifetimeScope()实例
.on已激活(x=>x.Instance.FileDetector=new LocalFileDetector());
}
我们在节点上得到这个:

root@docker-desktop:/# java -jar standalone.jar node --allow-cors --publish-events tcp://192.168.50.16:4442 --subscribe-events tcp://192.168.50.16:4443 --config nodeConfig.json --allow-cors
02:24:11.283 INFO [LoggingOptions.getTracer] - Using OpenTelemetry for tracing
02:24:11.285 INFO [LoggingOptions.createTracer] - Using OpenTelemetry for tracing
02:24:11.323 INFO [EventBusOptions.createBus] - Creating event bus: org.openqa.selenium.events.zeromq.ZeroMqEventBus
02:24:11.374 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://192.168.50.16:4442 and tcp://192.168.50.16:4443
02:24:11.427 INFO [UnboundZmqEventBus.<init>] - Sockets created
02:24:11.454 INFO [UnboundZmqEventBus.lambda$new$2] - Bus started
02:24:11.776 INFO [NodeServer.execute] - Reporting self as: http://192.168.65.3:5555
02:24:11.860 INFO [NodeOptions.report] - Adding Edge for {"browserName": "MicrosoftEdge"} 2 times
02:24:12.094 INFO [NodeServer.execute] - Started Selenium node 4.0.0-alpha-6 (revision 5f43a29cfc): http://192.168.65.3:5555
02:24:12.100 INFO [NodeServer.execute] - Starting registration process for node id e5e8efd9-e217-4967-8cfe-e312e7565523
02:24:12.398 INFO [NodeServer.lambda$execute$0] - Node has been added
Starting MSEdgeDriver 88.0.692.0 (dcff1d910f6557f2cce9c685f757a5891423af0c) on port 21256
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
Starting MSEdgeDriver 88.0.692.0 (dcff1d910f6557f2cce9c685f757a5891423af0c) on port 11003
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
Starting MSEdgeDriver 88.0.692.0 (dcff1d910f6557f2cce9c685f757a5891423af0c) on port 24739
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
Starting MSEdgeDriver 88.0.692.0 (dcff1d910f6557f2cce9c685f757a5891423af0c) on port 16505
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
测试输出:

System.invalidoOperationException
无法为创建会话
构建信息:版本:“4.0.0-alpha-7”,修订版:“117b9d61c9”
系统信息:主机:'836e92c76b1f',ip:'172.17.0.5',os.name:'Linux',os.arch:'amd64',os.version:'4.9.184-linuxkit',java.version:'1.8.0_265'
驱动程序信息:Driver.version:未知(SessionNotCreated)
在OpenQA.Selenium.Remote.RemoteWebDriver.UnpackantRownerError(响应错误响应)中
在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(stringdrivercommandtoexecute,Dictionary`2参数)
在OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
在OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor命令执行器,ICapabilities desiredCapabilities)
在OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress、ICapabilities desiredCapabilities、TimeSpan commandTimeout)
编辑1: 尝试将selenium alpha-7作为节点运行时,我得到以下结果:

root@docker-desktop:/# java -jar standalone-4.0-alpha-7.jar node --allow-cors --publish-events tcp://192.168.50.16:4442 --subscribe-events tcp://192.168.50.16:4443 --config nodeConfig.json
15:26:00.250 INFO [LogManager$RootLogger.log] - Using the system default encoding
15:26:00.253 INFO [LoggingOptions.getTracer] - Using OpenTelemetry for tracing
15:26:00.253 INFO [LoggingOptions.createTracer] - Using OpenTelemetry for tracing
15:26:00.319 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://192.168.50.16:4442 and tcp://192.168.50.16:4443
15:26:00.358 INFO [UnboundZmqEventBus.<init>] - Sockets created
15:26:00.360 INFO [UnboundZmqEventBus.lambda$new$7] - Bus started
15:26:00.576 INFO [NodeServer.createHandlers] - Reporting self as: http://192.168.65.3:5555
15:26:00.581 INFO [LoggingOptions.getTracer] - Using OpenTelemetry for tracing
15:26:00.583 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://192.168.50.16:4442 and tcp://192.168.50.16:4443
15:26:00.585 INFO [UnboundZmqEventBus.<init>] - Sockets created
15:26:00.586 INFO [UnboundZmqEventBus.lambda$new$7] - Bus started
Exception in thread "main" java.lang.IllegalArgumentException: Unable to find class: org.openqa.selenium.grid.node.local.LocalNodeFactory
        at org.openqa.selenium.grid.config.Config.getClass(Config.java:74)
        at org.openqa.selenium.grid.config.MemoizedConfig.lambda$getClass$4(MemoizedConfig.java:99)
        at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1688)
        at org.openqa.selenium.grid.config.MemoizedConfig.getClass(MemoizedConfig.java:95)
        at org.openqa.selenium.grid.node.config.NodeOptions.getNode(NodeOptions.java:74)
        at org.openqa.selenium.grid.node.httpd.NodeServer.createHandlers(NodeServer.java:122)
        at org.openqa.selenium.grid.node.httpd.NodeServer.asServer(NodeServer.java:176)
        at org.openqa.selenium.grid.node.httpd.NodeServer.execute(NodeServer.java:217)
        at org.openqa.selenium.grid.TemplateGridCommand.lambda$configure$2(TemplateGridCommand.java:98)
        at org.openqa.selenium.grid.Main.launch(Main.java:154)
        at org.openqa.selenium.grid.Main.go(Main.java:88)
        at org.openqa.selenium.grid.Main.main(Main.java:54)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.openqa.selenium.grid.config.Config.getClass(Config.java:69)
        ... 11 more
Caused by: java.lang.NoSuchMethodError: java.io.FileReader.<init>(Ljava/io/File;Ljava/nio/charset/Charset;)V
        at org.openqa.selenium.net.LinuxEphemeralPortRangeDetector.getInstance(LinuxEphemeralPortRangeDetector.java:36)
        at org.openqa.selenium.net.PortProber.<clinit>(PortProber.java:42)
        at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:401)
        at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:119)
        at org.openqa.selenium.chrome.ChromeDriverInfo.isAvailable(ChromeDriverInfo.java:57)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
        at java.util.Iterator.forEachRemaining(Iterator.java:116)
        at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
        at org.openqa.selenium.grid.node.config.NodeOptions.discoverDrivers(NodeOptions.java:187)
        at org.openqa.selenium.grid.node.config.NodeOptions.getSessionFactories(NodeOptions.java:84)
        at org.openqa.selenium.grid.node.local.LocalNodeFactory.create(LocalNodeFactory.java:66)
        ... 16 more
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.
SLF4J: Ignoring binding found at [jar:file:/standalone-4.0-alpha-7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation.
从中心:

16:26:36.171 WARN [SpanWrappedHttpHandler.execute] - Unable to execute request: Unauthorized access attempted to
Build info: version: '4.0.0-alpha-7', revision: '117b9d61c9'
System info: host: '836e92c76b1f', ip: '172.17.0.5', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.184-linuxkit', java.version: '1.8.0_265'
Driver info: driver.version: unknown
org.openqa.selenium.WebDriverException: Unauthorized access attempted to
Build info: version: '4.0.0-alpha-7', revision: '117b9d61c9'
System info: host: '836e92c76b1f', ip: '172.17.0.5', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.184-linuxkit', java.version: '1.8.0_265'
Driver info: driver.version: unknown
        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.grid.web.ErrorCodec.decode(ErrorCodec.java:141)
        at org.openqa.selenium.grid.web.Values.get(Values.java:47)
        at org.openqa.selenium.grid.node.remote.RemoteNode.newSession(RemoteNode.java:114)
        at org.openqa.selenium.grid.distributor.model.Slot.lambda$onReserve$2(Slot.java:84)
        at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:208)
        at org.openqa.selenium.grid.distributor.Distributor.lambda$new$0(Distributor.java:89)
        at org.openqa.selenium.remote.http.Route$TemplatizedRoute.handle(Route.java:183)
        at org.openqa.selenium.remote.http.Route.execute(Route.java:67)
        at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:327)
        at org.openqa.selenium.remote.http.Route.execute(Route.java:67)
        at org.openqa.selenium.grid.distributor.Distributor.execute(Distributor.java:124)
        at org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)
        at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
        at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:327)
        at org.openqa.selenium.remote.http.Route.execute(Route.java:67)
        at org.openqa.selenium.grid.router.Router.execute(Router.java:85)
        at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
        at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:327)
        at org.openqa.selenium.remote.http.Route.execute(Route.java:67)
        at org.openqa.selenium.grid.server.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:30)
        at org.openqa.selenium.grid.server.WrapExceptions.lambda$apply$0(WrapExceptions.java:36)
        at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
        at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:46)
        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)
16:26:36.172 WARN [LoggingOptions$1.lambda$export$1] - {"traceId": "6c98780410750ac145fcc0bcdc6075f1","spanId": "1a237f64fb417958","spanKind": "INTERNAL","eventTime": 1605716796170301100,"eventName": "exception","attributes": {"exception.type": "org.openqa.selenium.WebDriverException","exception.message": "Unable to execute request: Unauthorized access attempted to \nBuild info: version: '4.0.0-alpha-7', revision: '117b9d61c9'\nSystem info: host: '836e92c76b1f', ip: '172.17.0.5', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.184-linuxkit', java.version: '1.8.0_265'\nDriver info: driver.version: unknown","http.handler_class": "org.openqa.selenium.grid.distributor.local.LocalDistributor","http.url": "\u002fsession","exception.stacktrace": "org.openqa.selenium.WebDriverException: Unauthorized access attempted to \nBuild info: version: '4.0.0-alpha-7', revision: '117b9d61c9'\nSystem info: host: '836e92c76b1f', ip: '172.17.0.5', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.184-linuxkit', java.version: '1.8.0_265'\nDriver info: driver.version: unknown\n\tat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)\n\tat sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)\n\tat sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)\n\tat java.lang.reflect.Constructor.newInstance(Constructor.java:423)\n\tat org.openqa.selenium.grid.web.ErrorCodec.decode(ErrorCodec.java:141)\n\tat org.openqa.selenium.grid.web.Values.get(Values.java:47)\n\tat org.openqa.selenium.grid.node.remote.RemoteNode.newSession(RemoteNode.java:114)\n\tat org.openqa.selenium.grid.distributor.model.Slot.lambda$onReserve$2(Slot.java:84)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:208)\n\tat org.openqa.selenium.grid.distributor.Distributor.lambda$new$0(Distributor.java:89)\n\tat org.openqa.selenium.remote.http.Route$TemplatizedRoute.handle(Route.java:183)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:67)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:327)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:67)\n\tat org.openqa.selenium.grid.distributor.Distributor.execute(Distributor.java:124)\n\tat org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:327)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:67)\n\tat org.openqa.selenium.grid.router.Router.execute(Router.java:85)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:327)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:67)\n\tat org.openqa.selenium.grid.server.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:30)\n\tat org.openqa.selenium.grid.server.WrapExceptions.lambda$apply$0(WrapExceptions.java:36)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:46)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n","http.method": "POST"}}
从节点:

16:26:36.070 WARN [RequiresSecretFilter.isSecretMatch] - Unexpectedly received registration secret to (POST) /se/grid/node/session
16:26:36.078 WARN [LoggingOptions$1.lambda$export$0] - {"traceId": "7bd8f4e2a6a68f396b4d73d7ce41920e","spanId": "413eadfe028cb4f3","spanKind": "INTERNAL","eventTime": 1605716796076570700,"eventName": "HTTP request execution complete","attributes": {"http.status_code": 401,"http.handler_class": "org.openqa.selenium.grid.security.RequiresSecretFilter$$Lambda$356\u002f0x0000000840219040","http.url": "\u002fse\u002fgrid\u002fnode\u002fsession","http.method": "POST"}}

16:26:36.164 WARN [RequiresSecretFilter.isSecretMatch] - Unexpectedly received registration secret to (POST) /se/grid/node/session
16:26:36.165 WARN [LoggingOptions$1.lambda$export$0] - {"traceId": "c71c7cc95c85b1d892a913a8487a3bb3","spanId": "e7cad4724bde618f","spanKind": "INTERNAL","eventTime": 1605716796164917000,"eventName": "HTTP request execution complete","attributes": {"http.status_code": 401,"http.handler_class": "org.openqa.selenium.grid.security.RequiresSecretFilter$$Lambda$356\u002f0x0000000840219040","http.url": "\u002fse\u002fgrid\u002fnode\u002fsession","http.method": "POST"}}

16:26:45.135 INFO [LoggingOptions$1.lambda$export$0] - {"traceId": "f9aa30acdd23b666a00fd12d1e9171de","spanId": "3a26d851115e4ed8","spanKind": "INTERNAL","eventTime": 1605716805135500700,"eventName": "HTTP request execution complete","attributes": {"http.status_code": 200,"http.handler_class": "org.openqa.selenium.remote.http.Route$TemplatizedRoute","http.url": "\u002fstatus","http.method": "GET"}}

16:26:56.789 INFO [LoggingOptions$1.lambda$export$0] - {"traceId": "0be52be996fecb3cfeb4981cc69e4719","spanId": "034962023cad771b","spanKind": "INTERNAL","eventTime": 1605716816788987800,"eventName": "HTTP request execution complete","attributes": {"http.status_code": 200,"http.handler_class": "org.openqa.selenium.remote.http.Route$TemplatizedRoute","http.url": "\u002fstatus","http.method": "GET"}}
删除:

“webdriver.edge.driver”:“msedgedriver”,
功能中
,添加:

-Dwebdriver.edge.driver=/path/to/msedgedriver
到您的节点调用。例如:

java -jar /path/to/selenium-standalone.jar -Dwebdriver.edge.driver=/path/to/msedgedriver -role node -nodeConfig /path/to/node-config.json
啊,你的
browserName
必须是
MicrosoftEdge
(你有它,但向阅读本文的其他人提及它)


这对我的Selenium 3很管用。

刚刚在Ubuntu(不带docker)机器上试用了它,带有4.0.0-alpha-7、MSEdgeDriver 88.0.692.0和Edge for linux以及grid(集线器+节点)设置。工作正常。检查您在其日志中使用的节点版本,其中显示“[NodeServer.execute]-已启动Selenium节点4.0.0-alpha-6(修订版5f43a29cfc)”&集线器为alpha-7。对节点和集线器使用相同的版本,然后再试一次..Net5-selenium(alpha7)的.Net绑定中也出现了错误。如果使用RemoteWebdriver,则会导致异常内容类型标头丢失。在Java binding alpha 7中,它的固定和工作方式我不确定。。也许这很重要。您有
下载。默认的\u目录
首选项设置为windows样式,如
C:\\Users\\..
但是您正在Ubuntu中运行浏览器。@RahulL我尝试了alpha-7,但在更新到java 11后从编辑器中得到错误,此错误不再可用
java -jar /path/to/selenium-standalone.jar -Dwebdriver.edge.driver=/path/to/msedgedriver -role node -nodeConfig /path/to/node-config.json