TypeError:“ WebElement”对象不是使用Selenium和Python提交表单的下标错误

Jbsparrow

我正在尝试自动执行抽签剪辑,以获取他在鳕鱼上所作的出色表演,但遇到一些问题。

这是我设置的测试表格,与将要正常提交的一个剪辑相同-https: //forms.gle/MDMM3buW2DT5erpp8

from selenium import webdriver

option = webdriver.ChromeOptions()
option.add_argument("-incognito")


browser = webdriver.Chrome(executable_path='/Users/Goldilocks/Downloads/chromedriver', options=option)

browser.get("https://forms.gle/MDMM3buW2DT5erpp8")

clipDescription = "streamer sticks juggernaut with semtex for the win!"
clipLink = "https://twitch.tv/joocylad"
textboxes = browser.find_elements_by_class_name("quantumWizTextinputPaperinputInput")
radiobuttons = browser.find_elements_by_class_name("docssharedWizToggleLabeledLabelWrapper")
submitbutton = browser.find_element_by_class_name("appsMaterialWizButtonPaperbuttonContent")


radiobuttons[3].click()

radiobuttons[2].click()

textboxes[0].send_keys("JoocyLad")

textboxes[1].send_keys(clipLink)

textboxes[2].send_keys(clipDescription)

textboxes[3].send_keys("email")


submitbutton[0].click()

browser.close()

代码还没有完全完成,我要编写clipLinkclipDescription放入运行程序时需要输入的变量,但是我还没有解决。

我遇到的问题是第二个多项选择题没有填写。我也收到错误消息:

Traceback (most recent call last):
  File "/Users/Goldilocks/PycharmProjects/pythonProject/test.py", line 31, in <module>
    submitbutton[0].click()
TypeError: 'WebElement' object is not subscriptable

我使用的是谷歌chrome版本87.0.4280.88,而chrome驱动程序是同一版本87.0.4280.88

DebanjanB

此错误消息...

TypeError: 'WebElement' object is not subscriptable

...表示您已向WebElement添加了无法下标的索引索引可用于访问列表的元素


find_element_by_class_name()

find_element_by_class_name() 通过类名称在此元素的子元素中找到一个元素。

find_element_by_class_name()返回单个元素时,它没有索引且不可下标。


您需要从行中删除索引submitbutton[0].click()因此,您的有效代码行将是:

submitbutton.click()

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TypeError:“ map”对象不是Python 3中的下标错误

TypeError:“ WebElement”对象不是可迭代错误

Python Selenium TypeError:无法连接“ str”和“ WebElement”对象

Selenium / Python TypeError:“ WebElement”对象不可迭代

TypeError:使用来自Selenium Python的text(),'str'对象不是可调用错误

Python Selenium TypeError:“NoneType”对象不可下标

错误:TypeError:在python中使用lops时'int'对象不可下标

TypeError:'float'对象不可下标--Python

TypeError:“ int”对象不可下标{Python}

Python:TypeError:“ int”对象不可下标

Python TypeError:“设置”对象不可下标

TypeError:“ NoneType”对象不可下标(PYTHON)

Python TypeError:“函数”对象不可下标

TypeError:对象不可下标

TypeError:“ WebElement”对象不可迭代

“ TypeError:对象不是函数”

OpenCV示例错误-TypeError:“ NoneType”对象不可下标

获取“ TypeError:'NoneType'对象不可下标”错误

TypeError:'float'对象在python 3中不是可迭代的错误

TypeError:“模块”对象在MacOS上使用Selenium的ChromeDriver和Chrome无法调用错误

NLTK python错误:“ TypeError:'dict_keys'对象不可下标”

尝试在Python上实施Lisp程序-错误:builtins.TypeError:“ int”对象无法下标

使用Geopy进行地理定位失败,发生名义错误:TypeError:“ NoneType”对象不可下标

提交表单时出现TypeError

需要Python和SQLite帮助-> TypeError:“ NoneType”对象不可下标

我如何解决TypeError:使用flask和Sqlite3时'NoneType'对象无法下标?

使用Python 3.5,抛出错误:TypeError:需要一个类似字节的对象,而不是'str'

Python-TypeError:“ NoneType”对象不可下标

Python重新申请/搜索TypeError:“ NoneType”对象不可下标