我试图添加脚本以单击继续选项,但它给了我这个选项,如果有人可以帮助我,我下一步应该做什么。
from selenium import webdriver
driver = webdriver.Chrome("C:/Users/deepak/PycharmProjects/chromedriver.exe")
driver.get("https://www.tppcrpg.net/login.php")
# identify username, password and signin elements
driver.find_element_by_name("LoginID").send_keys("3480199")
driver.find_element_by_name("NewPass").send_keys("12")
driver.find_element_by_class_name("submit").click()
driver.get("https://www.tppcrpg.net/battle_trainer.php")
# identify Enter Trainer Name/Number
driver.find_element_by_name("Trainer").send_keys("2502909")
driver.find_element_by_class_name("submit").click()
driver.find_element_by_class_name("submit").click()
它在这里工作正常,但是当我再次添加这一行以单击继续按钮时
driver.find_element_by_class_name("submit").click()
然后这给了我这个错误
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".submit"}
(Session info: chrome=90.0.4430.72)
最佳答案
使用下面的 xpath 作为继续按钮。它对我有用
//input[@value='Continue >>']
代码:
driver.find_element_by_xpath("//input[@value='Continue >>']").click()
关于python - python中的selenium无法定位元素以单击继续按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67150455/