Python Selenium 选择国家/地区列表的下拉菜单

问题描述 投票:0回答:1

我正在编写一个 python 脚本来使用 selenium 从 CSV 文件填写表单。到目前为止,除了选择国家/地区列表之外,大部分功能都可以正常工作。我通过 ID 和 XPATH 都尝试过。这是我的下拉菜单部分:

Country=driver.find_element(By.ID('select-145')).get_attribute("innerHTML")
select=Select(Country)
Country.select_by_visible_text(ClientCountry)

我收到的错误是这样的:

Country=driver.find_element(By.ID('select-145')).get_attribute("innerHTML") ^^^^^^^^^^^^^^^^^^^ TypeError: 'str' object is not callable

python-3.x selenium-webdriver selenium-chromedriver
1个回答
0
投票

K..经过很多很多的故障排除...我终于弄清楚了...

 Country=driver.find_element(By.XPATH, "full-xpath-pasted-here"); countryselect=Select(Country); countryselect.select_by_visible_text(ClientCountry)

我确实以为我以前有过这个,但我认为我一开始在第三个命令中输入了错误的变量。我想我有

ClientCountry
而不是
countryselect

© www.soinside.com 2019 - 2024. All rights reserved.