1

I am trying to Click the Radio Button "Monthly (Final)" in the left side tab.

Please find the link https://socds.huduser.gov/permits/index.html?

Here is the Code which i tried,

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"
3
  • 1
    Please mention the issue in you question not in comments of your code. you haven't mentioned what is going wrong exactly. Commented Nov 17, 2017 at 6:25
  • you have used " " " in your xpath. " " " is treated as comments. Commented Nov 17, 2017 at 6:27
  • @PrakashPalnati, """string""" is not a comment, but a simple string Commented Nov 17, 2017 at 6:32

1 Answer 1

2

Radio button located inside an iframe. To be able to click it you should swith to iframe first:

driver.switch_to.frame('select')
Radio = driver.find_element_by_xpath("""//input[@value="monthlyF"]""")
Radio.click()
Sign up to request clarification or add additional context in comments.

2 Comments

How did you get that as XPath. My XPath was different
I just write my own while I guess you get it with browser dev console or other tool. You need to improve your skills in writing your own relative XPath expressions as using absolute XPath that online tool generated for you is bad practice...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.