我想创建允许填写注册,授权和其他文本形式的功能。就像是:
def fill_form(my_list):
forms = driver.find_elements_by_xpath(common_xpath)
for element in forms:
element.send_keys(my_list[forms.index(element)])
它应该得到作为参数的文本值的列表发送到<input type="text">
,<input type="password">
和<textarea>
元素。
到目前为止,我有:
common_xpath ='//input[@type="text" or @type="password"]'
但我不明白如何在此添加textarea
元素以XPath
使其匹配
一种更简单且更具前瞻性的策略是将XPath表达式分成搜索所需WebElement的2/3个不同的表达式,但是如果您确实需要使用单个XPath表达式,我想您可以使用|
运算符来设计一些东西的:
//input[@type="text" or @type="password"] | //textarea
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句