lefthandedgoat / canopy

f# web automation and testing library, built on top of Selenium (friendly to c# also)
http://lefthandedgoat.github.io/canopy/
MIT License
508 stars 115 forks source link

Error: Loading of unpacked extensions is disabled by the administrator #370 #376

Open sprice9161 opened 7 years ago

sprice9161 commented 7 years ago

I just wanted to followup with information that may be useful to the group for a period of time. Without rehashing the history of the ticket or the trouble shooting.

The original issue: "Error Loading Extension":"Failed to load extension from C:\User... Loading of unpacked extensions is disabled by the administrator". Is an error because the chrome extension detected by the failure is not whitelisted in our regulated environment.

When Canopy (Or Selenium running from SoapUI) attempts to simply launch the chrome browser, chromedriver.exe sends a flag to chrome indicating that an extension to be downloaded and installed. The extension is "Chrome Automation Extension" as it is referred to in the chromium ticket. the user is unaware and has no control over this. Thus the message in the popup box and the install path to the users temp directory is listed. Viewing the directory only shows the remnants of failed attempts. Disabling extension via the chromeOptions class doesn't work.

chromeOptions.AddArguments("--disable-extensions");

The workaround is:

chromeOptions.setExperimentalOption("useAutomationExtension", false);

This inhibits the attempt to install the extension. This makes sense since the browser displays a message that it is under automation control, so installing an extension meant specifically to aid in the control of the browser window for the purpose of automation makes sense, but that doesn't fly with IT security group. This has been verified running Selenium from soapUI

The chromium ticket does provide the extension id, suggesting that whitlisting the extension will solve the issue. This was not the case for me. I worked with our group, we whitelisted and updated policy rules but this still fails. I believe that this fails for the following reason, but I'm not positive. The ID no longer shows up as a valid extension in the Chrome store, Chromedriver.exe (v2.30) is still passing the flag to chrome (v59). Information in the ticket indicates that the fix is to move the extensions functionality into Developer Tools and eliminate the extension. This may have been what happend, and as of yet there is no current version of chromedriver.exe to support chrome v61.

This issue still exists in Canopy. The "start" command would need to be modified to include the workaround above, or something like:

let chromeOptions = OpenQA.Selenium.Chrome.ChromeOptions()
chromeOptions.setExperimentalOption("useAutomationExtension", false);
start <| ChromeWithOptions chromeOptions

BUT....the method setExperimentalOption isn't valid in C#/F# from what I can find in the API doc's so as of now I have no workaround for launching chrome in my environment. Hopefully a new version of chromedriver.exe will come out matching the changes made in chrome v61.

I'm including StackOverflow and Chromium ticket links. I will update this ticket once a solution is found. I hope that someone finds this helpful.

Related Links:

https://stackoverflow.com/questions/43797119/failed-to-load-extension-from-popup-box-while-running-selenium-scripts https://stackoverflow.com/questions/43079018/selenium-chromedriver-failed-to-load-extension

https://bugs.chromium.org/p/chromedriver/issues/detail?id=1763 https://bugs.chromium.org/p/chromedriver/issues/detail?id=1749

sprice9161 commented 7 years ago

I hope that providing this followup is alright. I tried to update the original ticket but access was restricted. There were so many users reporting this, that I thought it may be helpful.

sprice9161 commented 7 years ago

For anyone working with F#/C#, you can use the following code to launch the browser:

let chromeOptions = OpenQA.Selenium.Chrome.ChromeOptions()
chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
start <| ChromeWithOptions chromeOptions

I tried it and the Chrome browser launched successfully. Maybe you folks could run your own test and add the chromeOption line to the existing "start" method, until the the issue is resolved with a new chromedriver.exe and chrome pairing that corrects the issue.

Actions pin, pinToMonitor, positionBrowser, and any other window related action is going to have a problem. Since the extension isn't loaded, chromeOption will need to replace the tasks. I.e. chromeOptions.AddArgument("window-size=1920,1080")

manishdube commented 6 years ago

hello sprice9161. I am struggling with this exact same issue when implementing a canopy based test automation framework at a new gig. Where exactly in Chris's canopy starterkit would i plug in the below as you suggest in anearlier post.

let chromeOptions = OpenQA.Selenium.Chrome.ChromeOptions() chromeOptions.AddAdditionalCapability("useAutomationExtension", false); start <| ChromeWithOptions chromeOptions

I am working with Chris's starterkit and plan to build upon it.

@lefthandedgoat

manishdube commented 6 years ago

error- loading of unpacked extensions Hello Chris, From the attached image of the code. I tried to handle this error from the above comments but the reporter chrome instance still throws the exception box on initial load. How would i implement the items in the red box for the reporter chrome instance. I was able to handle that for the chrome browser i am opening for running the test. Thanks and regards.

lefthandedgoat commented 6 years ago

@manishdube You are saying that things are working for the normal browser but not the one started by the reporter?

Move your let chromeOptions =... above the reporter line and try something like this

LiveHtmlReporter((ChromeWithOptions chromeOptions), ....

manishdube commented 6 years ago

Works wonderfully well. Thanks a lot. below is what my testmain.fs looks like (for others who are experiencing the same issue)

module testmain
open canopy
open canopy.reporters
open System

let appName = AppDomain.CurrentDomain.FriendlyName.Replace(".exe", "")

[<EntryPoint>]
let main argv =
    configuration.elementTimeout <- 45.0
    hideCommandPromptWindow <- false

    let executionTime =  DateTime.Now
    let dtString = executionTime.ToString "yyyy-MM-dd-HHmm"

    let chromeOptions = OpenQA.Selenium.Chrome.ChromeOptions()
    chromeOptions.AddAdditionalCapability("useAutomationExtension", false);

    reporter <- new LiveHtmlReporter((ChromeWithOptions chromeOptions), AppDomain.CurrentDomain.BaseDirectory + @"\BrowserSupport") :> IReporter
    reporter.setEnvironment "stage.fepblue.org"

    let liveHtmlReporter  = reporter :?> LiveHtmlReporter
    liveHtmlReporter.reportPath <- Some("logs\TestSummary-{dt}".Replace("{dt}", dtString))

    chromeDir <- (AppDomain.CurrentDomain.BaseDirectory + @"\BrowserSupport")
    ieDir <- (AppDomain.CurrentDomain.BaseDirectory + @"\BrowserSupport")

    MyBlue_DMIPSMC_feature.all ()
    MyBlue_SecureMessageCenter_feature.all ()

    let chromeOptions = OpenQA.Selenium.Chrome.ChromeOptions()
    chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
    start <| ChromeWithOptions chromeOptions
    browser.Manage().Window.Maximize()

    run()
    quit()
    canopy.runner.failedCount 
manishdube commented 6 years ago

lines 16 - 19 did the trick. capture

hibaali77 commented 6 years ago

Hi, I have used "options.setExperimentalOption("useAutomationExtension", false);" in my code snippet as was discussed in one of the stack overflow links you have shared. But its again throwing a compilation error. What import do I need to use for object? image

lefthandedgoat commented 6 years ago

@hibaali77 Your code is java. You will need to google how to create new driver options and pass them into your driver instance when you create it.

amkrish05 commented 5 years ago

Tried with the setExperimentalOption and no such error found. Please refer the attached snap for more info. codesnippet

KomalaVignesh commented 4 years ago

I am trying to automate an application using JSR223 sampler in jmeter. I have added all the chrome driver options and desired capabilities, still im facing the failed to load unpacked extension error. This is happening only when i run the script from jmeter, when i run it in Eclipse using chrome driver options, its not happening.

Please help me to solve this...