Gulammustufa Momin
Gulammustufa Momin

Reputation: 71

Chrome is closed with error ERROR:network_change_notifier_win.cc(141)] WSALookupServiceBegin failed with: 0

My laptop OS is windows 10. I am using selenium webdriver with Python. When I open the chrome browser through the script, chrome is closed after loading the web page. Below is my code of python and error.

from selenium import webdriver

firfox_path = 'D:\Xampp7\htdocs\python_automation\Gecko_Driver\f_geckodriver-v0.26.0-win64\geckodriver.exe'

chrome_path = 'D:\Xampp7\htdocs\python_automation\Gecko_Driver\chromedriver_win32\chromedriver.exe'
browser = "chrome"

def open_chrome():
    driver = webdriver.Chrome(executable_path=chrome_path)
    driver.maximize_window()
    driver.get('http://seleniumhq.org/')

def open_firefox():
    driver = webdriver.Firefox(executable_path=firfox_path)
    driver.get('http://seleniumhq.org/')

if browser == "chrome":
    open_chrome()
elif browser == "firefox":
    open_firefox()

Error:

[6512:8744:0119/111722.550:ERROR:network_change_notifier_win.cc(141)] WSALookupServiceBegin failed with:0
DevTools listening on ws://127.0.0.1:63800/devtools/browser/bd82b677-7c97-47c6-9be1-5fae4ea25a9c
[13392:16912:0119/111722.621:ERROR:network_change_notifier_win.cc(141)] WSALookupServiceBegin failed with: 0

Upvotes: 2

Views: 7572

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193088

This error message...

ERROR:network_change_notifier_win.cc(141)] WSALookupServiceBegin failed with:0

...implies that WSALookupServiceBegin() method failed while trying to know whether or not there is network connection.

This error is defined in network_change_notifier_win.cc as follows:

bool NetworkChangeNotifierWin::IsCurrentlyOffline() const {

  // TODO(eroman): We could cache this value, and only re-calculate it on
  //               network changes. For now we recompute it each time asked,
  //               since it is relatively fast (sub 1ms) and not called often.

  EnsureWinsockInit();

  // The following code was adapted from:
  // http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/net/notifier/base/win/async_network_alive_win32.cc?view=markup&pathrev=47343
  // The main difference is we only call WSALookupServiceNext once, whereas
  // the earlier code would traverse the entire list and pass LUP_FLUSHPREVIOUS
  // to skip past the large results.

  HANDLE ws_handle;
  WSAQUERYSET query_set = {0};
  query_set.dwSize = sizeof(WSAQUERYSET);
  query_set.dwNameSpace = NS_NLA;
  // Initiate a client query to iterate through the
  // currently connected networks.
  if (0 != WSALookupServiceBegin(&query_set, LUP_RETURN_ALL,
                 &ws_handle)) {
    LOG(ERROR) << "WSALookupServiceBegin failed with: " << WSAGetLastError();
    return false;
  }

Solution

Check your inrernet connection and ensure that it doesn't breaks down in short time intervals.

Upvotes: 2

Related Questions