Unable to open chrome browser using Selenium Webdriver. Loading unpacked extensions are disabled by administrator(无法使用 Selenium Webdriver 打开 chrome 浏览器.管理员禁用加载解压缩的扩展程序)
问题描述
我正在使用 Selenium Webdriver、C#、Visual Studio 和 Chrome 浏览器自动化我的应用程序.
I am automating my application using Selenium Webdriver, C#, Visual Studio and Chrome browser.
当 selenium 尝试打开 chrome 浏览器时,我正在弹出以下窗口.
I am getting below popup when selenium tried to open the chrome browser.
Failed to load extension from:C:UsersVARA~1.PAKAppDataLocalTempscoped_dir6712_14913internal.
Loading of unpacked extensions is disabled by the administrator.
单击弹出窗口的确定"按钮后,Chrome 会成功打开,但由于以下错误,我的测试失败.
Once I click on OK button of the popup, Chrome is opening successfully but my test is failing due to below error.
Test Name: _3_EnterDetailsAndSelectAnAddress_John
Test FullName: Veolia.BrentGWP.UserStories.Features.BrentGWPFeature._3_EnterDetailsAndSelectAnAddress_John
Test Source: : line 2147483647
Test Outcome: Failed
Test Duration: 0:00:47.8059413
Result Message:
Test method Veolia.BrentGWP.UserStories.Features.BrentGWPFeature._3_EnterDetailsAndSelectAnAddress_John threw exception:
System.InvalidOperationException: unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=41.0.2272.118)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
Assert.Fail failed. Please check through the execution report against scenario
Result StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWindow.Maximize()
at Veolia.Libraries.Driver.BeforeScenario() in c:developmentVeolia.Web.Brentdevelopment estingAutomationVeolia.test.FrameworkLibrariesDriver.cs:line 105
at lambda_method(Closure , IContextManager )
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
at TechTalk.SpecFlow.Bindings.BindingInvokerExtensions.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, IContextManager contextManager, ITestTracer testTracer)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType bindingEvent)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioStart(ScenarioInfo scenarioInfo)
at TechTalk.SpecFlow.TestRunner.OnScenarioStart(ScenarioInfo scenarioInfo)
at Veolia.BrentGWP.UserStories.Features.BrentGWPFeature.ScenarioSetup(ScenarioInfo scenarioInfo) in c:developmentVeolia.Web.Brentdevelopment estingAutomationVeolia.test.FrameworkBrentGWPUserStoriesFeaturesAddressSearch.feature.cs:line 0
at Veolia.BrentGWP.UserStories.Features.BrentGWPFeature._3_EnterDetailsAndSelectAnAddress(String firstname, String lastname, String postcode, String email, String phoneNumber, String[] exampleTags) in c:developmentVeolia.Web.Brentdevelopment estingAutomationVeolia.test.FrameworkBrentGWPUserStoriesFeaturesAddressSearch.feature:line 16
at Veolia.BrentGWP.UserStories.Features.BrentGWPFeature._3_EnterDetailsAndSelectAnAddress_John() in c:developmentVeolia.Web.Brentdevelopment estingAutomationVeolia.test.FrameworkBrentGWPUserStoriesFeaturesAddressSearch.feature.cs:line 0
每次 selenium 打开 chrome 时,它都会将自动化扩展加载到 chrome 中以使用它.
Every time selenium open chrome it will load automation extension into chrome to work with it.
但在我们的组织中,我们正在使用 google 邮件,并且我们的 IT 部门出于安全原因阻止向 Chrome 浏览器添加扩展程序(第三方和解包).
But in our organization we are using google mail and our IT department blocked adding extensions(third party and unpacked) to Chrome browser for security reasons.
如果我修改注册表以允许第三方扩展,则测试执行成功.但是我们的 IT 部门每天都会在每个系统上更新政策(自动).
If I modified the registry to allow third party extensions, test is executing successfully. But our IT department updates the policy every day on every system(automated).
我尝试使用 ChromeOptions
类的 AddExtension
和 AddArgument
方法,但它们都没有工作并得到相同的错误.
I tried using AddExtension
and AddArgument
methods of ChromeOptions
class, but none of them worked and got the same error.
有人可以帮我解决这个问题吗?
Can someone help me to overcome this issue?
推荐答案
我尝试使用 ChromeOptions 类的 AddExtension 和 AddArgument 方法,但它们都不起作用并得到相同的错误.
I tried using AddExtension and AddArgument methods of ChromeOptions class, but none of them worked and got the same error.
我做了这样的事情(JAVA):
I did something like this (JAVA):
ChromeOptions o = new ChromeOptions();
o.addArguments("disable-extensions");
o.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(o);
第二行就是你所需要的.第三行只是让 chrome 窗口最大化.
The second line is all what you need. The third line is just making chrome window maximized.
当前未显示弹出窗口.HTH.
The pop-up isn't showing up currently. HTH.
这篇关于无法使用 Selenium Webdriver 打开 chrome 浏览器.管理员禁用加载解压缩的扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法使用 Selenium Webdriver 打开 chrome 浏览器.管理员禁用加载解压缩的扩展程序
基础教程推荐
- SSE 浮点算术是否可重现? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30