0

I am working on selenium and python. I am unable to select the radio button. I want to add the values in a list. and iterate and click on the specific radio button.

 def test_search_in_python_org(self):
        driver = self.driver
        driver.get("https://www.makemytrip.com")


        driver.find_element_by_xpath("//a[normalize-space()='ROUND TRIP']").click()

enter image description here

error

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a[normalize-space()='ROUND TRIP']"}

1 Answer 1

2

I don't think you need to iterate through them.

Just target the correct element, your xpath could look like this:

//li[@data-cy='roundTrip']

One of the problems with your current xpath is you're trying to find an 'a' element, where the fake radio buttons are actually 'li' elements.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.