0
   <label for="CREDIT" class="_8J-bZE _3C6tOa _2i24Q8">
        <input type="radio" class="_2haq-9" name="paymentOptions" readonly="" id="CREDIT" value="on">
        <div class="_6ATDKp"></div>
         <div class="_2o59RR">
        </div>
        </label>

        <label for="NET_OPTIONS" class="_8J-bZE _3C6tOa _2i24Q8">
        <input type="radio" class="_2haq-9" name="paymentOptions" readonly="" id="NET_OPTIONS" value="on">
        <div class="_6ATDKp"></div>
        <div class="_2o59RR"></div>
        </label>

There are the two radio buttons with same class name and I want to click the second one ( NET OPTIONS). I am new to python and selenium both any help will be appriciated. I have tried Xpath and locating ID both but still NO sucess

driver.find_element_by_id("NET_OPTIONS").click()
driver.find_element_by_xpath("//*[@id='container']/div/div[1]/div/div/div[1]/div[4]/div/div/div/div[3]/div/label[3]").click()

after trying the above code , I am getting this error, However radio button is very much visible on the page but , webriver is nit able to locate it :( .selenium.common.exceptions.ElementNotVisibleException‌​: Message: element not visible

7
  • Use find_element_by_id(). Commented Aug 27, 2017 at 3:47
  • Check if your radio button located inside an iframe Commented Aug 27, 2017 at 6:38
  • what is the error you are getting? Commented Aug 27, 2017 at 9:42
  • Thanks @Kapil for your reply .......selenium.common.exceptions.ElementNotVisibleException: Message: element not visible ....thts the error I am getting , radio button is very much visbible on the screen but somehow , slenium webdriver is unable to find it . Commented Aug 27, 2017 at 14:23
  • try this code and lets see if it works- element = driver.find_element_by_id("NET_OPTIONS") driver.execute_script("arguments[0].click();", element) Commented Aug 27, 2017 at 14:45

2 Answers 2

1

try this code and lets see if it works-

 element = driver.find_element_by_id("NET_OPTIONS")
 driver.execute_script("arguments[0].click();", element)
Sign up to request clarification or add additional context in comments.

Comments

0

This is pretty straightforward. Assuming driver is your Selenium webdriver, you can click the button you want by simply finding it via it's id:

button = driver.find_element_by_id("NET_OPTIONS")
button.click()

Comments

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.