繁体   English   中英

下拉是隐藏的,不知道如何使用 selenium python 处理它?

[英]Drop down is hidden, Not sure how to handle it using selenium python?

所以下拉值在 select 标记以及行标记中可用。我提供了下面的代码截图。 select 标签 htmlli 标签 html或者如果您可以通过以下步骤看到下降

  1. Go 至https://www.us.kohler.com/us/
  2. 点击登录
  3. 点击注册
  4. 第 4 个字段是 drop down.that 魔鬼。

正如@Peres995 所指出的,您确实可以用文本填充该字段,您只需要 select 输入字段。

尝试:

country = 'Brazil'
_id = 'countryDropdown-account_titleText'
identifier = "//input[@id='{}']".format(_id)
# Make sure it's not invisible
driver.execute_script("document.getElementById('{}').setAttribute('style','display: initial;')".format(_id), identifier)
# Clear the field
driver.find_element_by_xpath(identifier).clear()
driver.find_element_by_xpath(identifier).send_keys('{country}'.format(country=country))

您可以使用文本填充该字段作为正常输入。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM