gpt4 book ai didi

python - 为什么我收到 NameError : name 'ActionChains' is not defined?

转载 作者:太空宇宙 更新时间:2023-11-04 02:29:53 26 4
gpt4 key购买 nike

我是 python 的新手,正在尝试自动填写网络表单。

我收到这个错误:

Traceback (most recent call last): File "main.py", line 24, in ActionChains(browser)\ NameError: name 'ActionChains' is not defined

这是我的代码:

from time import sleep
from selenium import webdriver

browser = webdriver.Chrome ('/Users/max/Downloads/chromedriver')

browser.get ('http://www.brix.de/computer/web_html_php_et_al/formular-test_smm_01.html')

inputs = browser.find_element_by_xpath(
'/html/body/form[1]/table')

ActionChains(browser)\
.move_to_element(input[vorname]).click()\
.send_keys('name')\
.move_to_element(input[name]).click()\
.send_keys('Surname')\
.perform()

有人可以帮帮我吗?

最佳答案

我认为您缺少导入,请尝试以下操作:

from time import sleep
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

browser = webdriver.Chrome ('/Users/kiran/Downloads/chromedriver')

browser.get ('http://www.brix.de/computer/web_html_php_et_al/formular-test_smm_01.html')

inputs = browser.find_element_by_xpath(
'/html/body/form[1]/table')

ActionChains(browser)\
.move_to_element(input[name]).click()\
.send_keys('name')\
.move_to_element(input[vorname]).click()\
.send_keys('Surname')\
.perform()

关于python - 为什么我收到 NameError : name 'ActionChains' is not defined?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49477856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com