0

Updated Chrome to 113.0.5672.127, downloaded ChromeDriver 113.0.5672.63 but scripts stopped working. Looks like first line of script where I try to manipulate elements on page are not working now no matter what.

Examples of error text:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//iframe"}
  (Session info: headless chrome=113.0.5672.127)

and:

WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[starts-with(@ng-click,'clickEdit')]"))).click()

It's literally first lines and they worked for months. Can someone help to understand what's the problem?

Tried to use other versions of ChromDriver but it didn't help.

Edit:

So after some reserch I found out that page had an error and this error is cause of my problems but looks like error was caused by my script after update in there first place. Now page is unavailable to me because of this error but I have over similar pages and can recreate the process.

Looks like if I run scrips with "chrome_options.add_argument("--headless")"(I want chrome to be hidden) I get this message in cmd window: DevTools listening on ws://127.0.0.1:52759/devtools/browser/05d5b34e-667c-4beb-a9a8-d87a52a3dd82 [0517/124106.941:INFO:CONSOLE(0)] "Autofocus processing was blocked because a document already has a focused element.", "link".

After that there is a error on this page and page is unavailable after that for me. But if I run script without "chrome_options.add_argument("--headless")" on page where is no error yet - all is good. Some crazy things is happening, can someone help to understand what is going on?

Антон
  • 23
  • 6

2 Answers2

1

Got answer in russian stack overflow. Need to edit from

chrome_options.add_argument("--headless")

to

chrome_options.add_argument("--headless=new")

more on the topic: Downloading with chrome headless and selenium

Антон
  • 23
  • 6
0

Try using Webdriver Manager for Python seems to work (albeit I am on a Mac so my version of Chrome is 113.0.5672.126 instead of 127 which is for Windows), here is a minimal example:

import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

# Setup Chrome options
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--remote-debugging-port=9222")
# Setup WebDriver
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
# Navigate to google.com
driver.get("https://google.com")
# Close the driver after 10 seconds
time.sleep(10)
driver.quit()
Sash Sinha
  • 18,743
  • 3
  • 23
  • 40