2

Recently Selenium chrome webdriver started to run into problems by triggering Microsoft Malicious Software Removal Tool to request if it may reset browser settings. How to get around this? Is there an argument to add to options like --disable-extensions solved a popup problem before?

    from selenium import webdriver
    options = webdriver.chrome.options.Options()
    options.add_argument("--disable-extensions")
    driver = webdriver.Chrome(chrome_options=options)

enter image description here

A temporary solution may be

driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'w')

but nothing happens.

What works (but obviously not ideal) is to execute javascript to close the undesired tab:

time.sleep(0.2) # give some time for the tabs to appear

# just to understand that the first tab is counter-intuitivly the last of window.handles change the content of each tap
js = "document.getElementsByTagName('body')[0].innerHTML = 'This is handle {0}: {1}';"
for i, handle in enumerate(driver.window_handles):
    driver.switch_to_window(handle)
    driver.execute_script(js.format(i,handle))

# now close the msrt tab and make the desired tab active    
handle_desired, handle_msrt = driver.window_handles # last handle is first tab
driver.switch_to_window(handle_msrt)
driver.execute_script('window.close()') # close the msrt tab
driver.switch_to_window(handle_desired)
Community
  • 1
  • 1
Remi
  • 20,619
  • 8
  • 57
  • 41
  • I've tried to figure out what's going on but didn't manage. Please, tell us how to get the same issue. I can't reproduce it. – Denis Koreyba Apr 12 '17 at 16:37
  • Using only the lines of code given in the question, the problem occurs. OS: Windows 10 with the [Microstoft MSR-Tool](https://support.microsoft.com/en-us/help/890830/the-microsoft-windows-malicious-software-removal-tool-msrt-helps-remove-specific,-prevalent-malicious-software-from-computers-that-are-running-supported-versions-of-windows) (which is installed by default and runs hidden as a process). – Remi Apr 13 '17 at 07:51

0 Answers0