python - python中的selenium无法定位元素以单击继续按钮

标签 python selenium selenium-webdriver

我试图添加脚本以单击继续选项,但它给了我这个选项,如果有人可以帮助我,我下一步应该做什么。

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()

enter image description here

它在这里工作正常,但是当我再次添加这一行以单击继续按钮时

driver.find_element_by_class_name("submit").click()

enter image description here

然后这给了我这个错误

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/

相关文章:

python - Selenium Webdriver 测试元素可见性的假阴性结果?

python - python中split()函数的空间复杂度

python - 我无法在 HTML 文件中输入要添加到购物车的数量订单 - Django

java - driver.quit() 导致 'Firefox to stop working'

python - Selenium webdriver 无法找到该元素。错误 - 消息 : element not visible

java - 在java中减少JPG文件的文件大小

python - Junit HTML 报告生成器

python - 如何使用python检查HDFS中是否存在文件

javascript - Selenium WebDriver 和通用等待或延迟

python - 我如何索引这个范围内的每个数字并用 Selenium 搜索它