'Using xpath method in selenium in python - no such element: Unable to locate element
kinda new in the selenium, I'm trying to reach a "submit" element in a very long xml page. Here is my code:
import pip
import time
import autoit
#import selenium
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome(executable_path=r"C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.10\chromedriver.exe")
driver.get("https://example.com/")
time.sleep(30)
element = driver.find_element(by=By.XPATH, value="//*[@id='btnLastMonth']")
I reached this xpath by clicking on the element from inspect > copy xpath. I keep getting this massage:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='btnLastMonth']"}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
