Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to open chrome browser using Selenium Webdriver. Loading unpacked extensions are disabled by administrator

I am automating my application using Selenium Webdriver, C#, Visual Studio and Chrome browser.

I am getting below popup when selenium tried to open the chrome browser.

Failed to load extension from:C:\Users\VARA~1.PAK\AppData\Local\Temp\scoped_dir6712_14913\internal.
Loading of unpacked extensions is disabled by the administrator.

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:\development\Veolia.Web.Brent\development\testing\Automation\Veolia.test.Framework\Libraries\Driver.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:\development\Veolia.Web.Brent\development\testing\Automation\Veolia.test.Framework\BrentGWP\UserStories\Features\AddressSearch.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:\development\Veolia.Web.Brent\development\testing\Automation\Veolia.test.Framework\BrentGWP\UserStories\Features\AddressSearch.feature:line 16
   at Veolia.BrentGWP.UserStories.Features.BrentGWPFeature._3_EnterDetailsAndSelectAnAddress_John() in c:\development\Veolia.Web.Brent\development\testing\Automation\Veolia.test.Framework\BrentGWP\UserStories\Features\AddressSearch.feature.cs:line 0

Every time selenium open chrome it will load automation extension into chrome to work with it.

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.

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).

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?

like image 893
VaraPrasad Pakalapati Avatar asked Dec 01 '22 17:12

VaraPrasad Pakalapati


1 Answers

I tried using AddExtension and AddArgument methods of ChromeOptions class, but none of them worked and got the same error.

I did something like this (JAVA):

ChromeOptions o = new ChromeOptions();
o.addArguments("disable-extensions");
o.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(o);

The second line is all what you need. The third line is just making chrome window maximized.

The pop-up isn't showing up currently. HTH.

like image 157
jakbeb Avatar answered Dec 05 '22 05:12

jakbeb