quick preface: I'm new to python and scraping so it's possible that I'm making an extremely obvious mistake.
I am trying to use Selenium to automate a few processes, the first of which is to open https://shop.anyseals.com/index.phtml and enter in a username and password.
This is how I am approaching it - A method that has worked for me without issue in the past with other websites.
from selenium import webdriver import time chromedriver = "A:\Downloads\chromedriver_win32 (1)/chromedriver" driver = webdriver.Chrome(chromedriver) driver.get("https://shop.anyseals.com/index.phtml") #Let's wait for X seconds so that the elements can load. time.sleep(3) user = "username@user.com" use = driver.find_element_by_xpath('//*[@id="userkey"]') use.send_keys(user)
I'm using the xpath from the html associated with the username input. (html shown below)
<input name="userkey" id="userkey" style="width:100%" type="text" onkeydown="if(event.keyCode=='13')perform_login('smp');">
I keep getting the error shown below that states that there is no such element. What am I missing here?
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="userkey"]"}
https://stackoverflow.com/questions/66913634/xpath-not-working-properly-with-selenium-python April 02, 2021 at 10:07AM
没有评论:
发表评论