[C#] Wny can't I control Chrome Selenium Web Driver under Internet disconnect [WebDriver Exception]

249 views
Skip to first unread message

TOAN

unread,
Mar 27, 2019, 6:03:47 PM3/27/19
to Selenium Users
Hello.
I'm is using Chrome Web Driver.
Automation test is no problem.

But, I have to test exception case.
Only Internet disconnect  test is problem.

[test case]
1. run tmy automation app.
2. turn off wi-fi connection off during normal operation.
3. I saw "ERR_INTERNET_DISCONNECTED "message  on chrome browser
4. after 1 minutes. OpenQA.Selenium.WebDriverException is occurred
    (As far as I know, The HTTP request to the remote WebDriver timed out after 60 seconds)
5. I caught exception with using try~catch.
    But, I can't control chrome web driver.
   _driver.Quit(), _driver.Close(), _driver.URL()..etc. No API calls are carried out.
   
   
   I don't understand, This is basic concept in webdriver or normal operatoin????
   We can make this exception case easily. If you  meet the same experience, Help me!!!.
   Frankly, I'm going to go away.

   
  Additionally,  After 5 step,  Turn-on wifi, and then current URL reload with using chrome web browser reload menu.
  Automation app is running automatically and close at once.
  As far as I'm concerned, Dirver api command(_driver.Quit()) in exceptoin was executed after wifi on and reload chrome browser.
  If it is true, We can't control chrome web driver Internet disconnect case?
  
  I have a headache for several days.

[code example]
       try { 
              _driver.FindElement(By.XPath(composeXPath)).Click();
             }
                catch (System.Net.WebException e)
                {
                    System.Diagnostics.Debug.WriteLine("[Web Actor]WebException expired");
                   
                }
                catch (System.Net.Sockets.SocketException e)
                {
                    System.Diagnostics.Debug.WriteLine("[Web Actor]SocketException expired");
                }

                catch (NoSuchElementException e)
                {
                    System.Diagnostics.Debug.WriteLine("[Web Actor]No such Element Exception");
                }
               
                catch (StaleElementReferenceException e)
                {
                    System.Diagnostics.Debug.WriteLine("[Web Actor]StaleElementReferenceException expired");
                    
                }
                catch (OpenQA.Selenium.UnhandledAlertException e)
                {
                    System.Diagnostics.Debug.WriteLine("[Web Actor]Unhandled Alert Action");
                    _driver.SwitchTo().Alert().Accept();
                }
                catch (OpenQA.Selenium.WebDriverException e)
                {
                
                    System.Diagnostics.Debug.WriteLine("[Web Actor]Web Driver Try to close");
                    //Quit,Close, 
                    _driver.Quit();

                    System.Diagnostics.Debug.WriteLine("[Web Actor]Web Driver Exception");
               
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("[Web Actor]Others Exception");
                }


Thanks.

TOAN

unread,
Apr 3, 2019, 11:56:03 PM4/3/19
to Selenium Users
I found solution. This is not my code issue.
This is mismatch among packages version.
Anyway, I changed package version as below. Then I didn't found previous issues.

  <package id="Selenium.Chrome.WebDriver" version="2.45" targetFramework="net461" />
  <package id="Selenium.WebDriver" version="3.14.0" targetFramework="net461" />

Thanks
  
2019년 3월 28일 목요일 오전 7시 3분 47초 UTC+9, TOAN 님의 말:
Reply all
Reply to author
Forward
0 new messages