我正在使用 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 浏览器.管理员禁用加载解压缩的扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!