Issue
I'm trying to write a script that opens my staging URL and clicks/sendskeys through a flow.
I'm getting stuck with errors that I think indicate the element isn't present ( Message: unknown error: result.webdriverValue.value list is missing or empty in Runtime.callFunctionOn response)
I'm a noob just tring to improve their life, so if anyone can diagnose my script I would greatly appreciate it.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
import time
chrome_driver_path = r"C:\Users\tyler\Downloads\chromedriver-win64\chromedriver-win64\chromedriver.exe"
service = Service(executable_path=chrome_driver_path)
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
try:
driver.get("my-staging-URL")
time.sleep(10)
driver.find_element("xpath", '/html/body/div[1]/div[1]/header/div[1]/div[2]/div/div[3]/div/button[2]/div/div/p').click()
time.sleep(5)
#driver.get("https://www.youtube.com/results?search_query=selenium+xpath")
except NoSuchElementException as e:
print("Element not found:", e)
input("Press any key to close the browser")
For more context, when I use this xpath in a tool like Katalon recorder it works fine.
Solution
That's not the right expression in selenium4.1......
driver.find_element(By.XPATH, '/html/body/div[1]/div[1]/header/div[1]/div[2]/div/div[3]/div/button[2]/div/div/p').click()
Answered By - Tououououer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.