下拉列表是隐藏的,不知道如何使用seleniumpython处理它?

2024-04-25 05:53:00 发布

您现在位置:Python中文网/ 问答频道 /正文

所以下拉值在selecttag和line tag中都可用。 select tag htmlli tag html 或者你可以通过以下步骤看到下降

  1. 转到https://www.us.kohler.com/us/
  2. 单击“登录”
  3. 单击“注册”
  4. 第四个领域是下降下来。那个魔鬼。你知道吗

Tags: httpscomhtmltagwwwline步骤li
1条回答
网友
1楼 · 发布于 2024-04-25 05:53:00

正如@Peres995所指出的,您确实可以用文本填充字段,您只需选择输入字段。你知道吗

尝试:

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

相关问题 更多 >