Search code examples
c#seleniumgoogle-chromeselenium-chromedriverazure-automation

System.InvalidOperationException : unknown error: Runtime.evaluate threw exception: DOMException error using Azure and Selenium through C#


I'm running tests on a Remote Machine through Azure daily scheduled run. Some of the tests are failing with below error log. How can I fix this ?

Note : I do not have method implementation of launching chrome driver as I am referencing dll of other solution which has abstract methods.

Stack : NUnit, C#, Selenium, Visual Studio, Azure, log4Net

OneTimeSetUp: Automation.Test.Framework.Models.Exceptions.AtGenericException : Error initializing WebDriver Chrome ----> System.InvalidOperationException : unknown error: Runtime.evaluate threw exception: DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document. at :1:1 (Session info: chrome=77.0.3865.90) (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.3.9600 x86_64)


Solution

  • This error message...

    OneTimeSetUp: Automation.Test.Framework.Models.Exceptions.AtGenericException : Error initializing WebDriver Chrome 
    System.InvalidOperationException : unknown error: Runtime.evaluate threw exception: DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document. at :1:1 (Session info: chrome=77.0.3865.90) 
    (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.3.9600 x86_64)
    

    ...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

    Your main issue is the incompatibility between the version of the binaries you are using as follows:

    • You are using chromedriver=2.36
    • Release Notes of chromedriver=2.36 clearly mentions the following :

    Supports Chrome v63-65

    Supports Chrome version 77

    So there is a clear mismatch between the ChromeDriver v2.36 and the Chrome Browser v77.0


    Solution

    Ensure that:

    • ChromeDriver is updated to current ChromeDriver v78.0 level.
    • Chrome is updated to current Chrome Version 78.0 level. (as per ChromeDriver v78.0 release notes)
    • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
    • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
    • Take a System Reboot.
    • Execute your @Test as non-root user.
    • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.