Home > Software design >  Can't find element in Selenium Python
Can't find element in Selenium Python

Time:10-20

I have been working on this problem for quite a bit now, and can't figure out why this is happening. I am trying to click a button. The button and the corresponding text always changes, but the XPATH stays the same. Button I am trying to click It doesn't work with CSS Selector either. I am using Chrome web version 106. Does anyone know why?

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException

PATH = r"C:\Users\###\Downloads\chromedriver.exe"
driver = webdriver.Chrome(PATH)


# time to login
driver.get("https://clever.com")
time.sleep(60)

try:
    driver.find_element(By.XPATH, '//*[@id="root"]/div/div/div[2]/div[3]/div/div/div/div[2]/button[2]').click()

except NoSuchElementException:
  print("no such element")
  pass

time.sleep(5)

Capturing the XPATH for the element

CodePudding user response:

Try this:

driver.find_element("xpath", '//*[@id="root"]/div/div/div[2]/div[3]/div/div/div/div[2]/button[2]').click()

May be you using not correct syntax

CodePudding user response:

I'm also having issues when I updated my webdriver to v106. Also seeing other users who have the same issue: https://groups.google.com/g/chromedriver-users/c/tKvIvChszu8

  • Related