Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python selenium select option from angular js drop down

Please open this website- https://mobikwik.com/
There is a form for Mobile with 2nd item as Select Operator.
I want to select - "Idea" from this drop down using selenium webdriver.
Please help.

Also, after selecting idea, i get a new drop down for select circle. Need to select Mumbai for it.

My attempt:

driver.find_element_by_css_selector("li > span.ng-binding").click()
driver.find_element_by_xpath("//label[3]/i").click()
driver.find_element_by_css_selector("font > label > i").click()
driver.find_element_by_xpath("//section[@id='mainunit']/div/div[2]/div/div[2]/div/div/div/form/div[4]/p/dl/dd/ul/li[9]/span").click()
driver.find_element_by_xpath("//font/label[2]/i").click()
like image 992
Saurabh Shrivastava Avatar asked Jul 02 '26 20:07

Saurabh Shrivastava


1 Answers

I tried this code with same webpage and worked:

driver.find_element_by_xpath("//span[contains(text(), 'Select Operator')]").click()
driver.find_element_by_xpath("//span[contains(text(), 'Idea')]/..").click()

It is essential that you first make visible the options pannel, otherwise it will throw the following exception:

selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with

Updated:

To select the Mumbai option:

driver.find_element_by_xpath("//span[contains(text(), 'Select Circle')]").click()
driver.find_element_by_xpath("//span[contains(text(), 'Mumbai')]/..").click()
like image 83
Javitronxo Avatar answered Jul 05 '26 10:07

Javitronxo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!