6

I am using a selenium headless Chrome on python to scrape a website. This website uses synchronous XMLHttpRequest, which is probably worse than asynchronous, but I don't really care (not my website). Each time my selenium webdriver visits this website, the Chrome deprecation message will be printed in my console:

"Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/."

How to stop this message from popping up?

timbre timbre
  • 12,648
  • 10
  • 46
  • 77
Myusico
  • 69
  • 4
  • Have you looked at [this post](https://stackoverflow.com/questions/28531743/synchronous-xmlhttprequest-on-the-main-thread-is-deprecated-using-nodejs-app-g?rq=1)? It looks like someone else was getting the same warning, albeit in a different context. – Mihai Chelaru May 10 '18 at 20:38

3 Answers3

3

This may have already been solved, but as this thread (link here) explains, adding a new argument will help.

options.add_argument("--log-level=3")
leopon
  • 31
  • 2
2

I faced this warning whenever I am using chrome driver with selenium. Normally, declare driver of chrome as:

driver = webdriver.Chrome(executable_path=PATH)

To this, we can pass one more argument, that is, options. Lets declare it first:

chrome_options = Options()
chrome_options.add_argument('--log-level=3') ## remove warining
chrome_options.add_argument("--headless") ## this will open chrome in backend, hence it will somehow boost processing.
driver = webdriver.Chrome(executable_path=PATH,options=chrome_options)

By this, warning will be removed. Thank you.

HITESH GUPTA
  • 149
  • 4
0

This works like a charm.

chrome_options.add_argument('--log-level=3')

Zeltrax
  • 1
  • 1