如何使用pythonselenium单击单选按钮

2024-04-26 05:21:16 发布

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

我正在尝试单击左侧选项卡中的“每月(最终)”单选按钮。在

请找到链接https://socds.huduser.gov/permits/index.html?在

这是我试过的密码

from selenium import webdriver
import time

chrome_path = r"/usr/bin/chromedriver"
driver = webdriver.Chrome(chrome_path)
driver.get("https://www.huduser.gov/portal/datasets/socds.html") # Hitting the Site
driver.maximize_window()
driver.find_element_by_xpath("""//*[@id="block-system-main"]/div[4]/div/div/div/div/form[5]/input""").click() #Clicking Buiding Permits Database
time.sleep(10)
### Not working ###
print driver.find_element_by_xpath("""/html/body/form/a[2]/input""").location # Getting the Location of the Element
Radio = driver.find_element_by_xpath("""/html/body/form/a[2]/input""") # Clicking Monthly Final Radio button
Radio.click()
driver.find_element_by_css_selector("body > form:nth-child(2) > a:nth-child(29) > input:nth-child(1)").click()
print "DONE"

Tags: thedivformchildinputbyhtmldriver