0

When I am trying to run the automation script without connecting to the internet, the below exception will be returned:

System.Net.WebException: 'The remote name could not be resolved: 'chromedriver.storage.googleapis.com''

Is there any way to execute the script without connecting to the internet (Offline), by using specific chrome version or the version cashed in the WebDriverManager?

enter image description here

enter image description here

  • The ChromeDriver's ChromeNetworkConditions should have the IsOffline Property... https://www.fuget.org/packages/Selenium.WebDriver/3.9.1/lib/net45/WebDriver.dll/OpenQA.Selenium.Chrome/ChromeNetworkConditions – Akshay G May 16 '21 at 07:29
  • The IsOffline property is used, but the exception still returned from WebDriverManager System.Net.WebException: 'The remote name could not be resolved: 'chromedriver.storage.googleapis.com'' – Ammar Al-Sadeq May 16 '21 at 08:03
  • 1
    Can you access website offline and perform the steps ? – cruisepandey May 16 '21 at 08:07
  • Yes, I have accessed this website without an internet connection https://chris.bolin.co/offline/ but the WebDriverManager still returns the same exception. – Ammar Al-Sadeq May 16 '21 at 08:14
  • are you trying to download the chrome web driver or using the local copy of exe?... Edit the post to include your code and highlight the line of code where it throws error. – Akshay G May 16 '21 at 08:15
  • I am trying to download the chrome driver using WebDriverManager. The question has been editied. Please check the attached screenshots. – Ammar Al-Sadeq May 16 '21 at 08:19
  • For another reasons I need to use the WebDriverManager So, in case I need to access website offline using WebDriverManager, this thing not doable using WebDriverManager? – Ammar Al-Sadeq May 16 '21 at 08:34
  • The WebDriverManager's sole purpose is to automate the process of downloading and referring the exe path/environment variable. It always checks for the latest version over the internet, downloads it and then uses that exe to instantiate. So you cannot use WebDriverManager in an offline mode. – Akshay G May 16 '21 at 08:49
  • Having said that you can create your own ChromeOfflineConfig which will inherit IdriverConfig – Akshay G May 16 '21 at 08:53
  • if you want to run the selenium tool in a server with no intermet access you can set up the proxy... new DriverManager().WithProxy(previouslyInitializedProxy).SetUpDriver(new ChromeConfig()); – Akshay G May 16 '21 at 09:01

1 Answers1

0

Download the chromedriver from: https://sites.google.com/chromium.org/driver/

Once you've downloaded the required files extract the zips to a local drive on your computer.

Make sure to add the path to where you extracting the chromedriver.exe

IWebDriver chromeDriver = new ChromeDriver(@ "D:\Download\chromedriver"); //<-Add your path

driver.NetworkConditions = new ChromeNetworkConditions() {
  IsOffline = true, DownloadThroughput = 5000, UploadThroughput = 5000, Latency = TimeSpan.FromMilliseconds(5)
};

driver.Navigate().GoToUrl("https://chris.bolin.co/offline/");

Note: You could also create an environment variable named webdriver.chrome.driver on your machine that's value is the path to where the local chromedriver.exe is located. If you set up a webdriver.chrome.driver variable you would not have to pass the chrome driver argument when you create a ChromeDriver instance

Akshay G
  • 2,070
  • 1
  • 15
  • 33