3

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()
5
  • Try this driver.find_element_by_xpath("//li[@class='ng-scope'][9]").click(). Commented Nov 4, 2015 at 11:04
  • To complete the comment of @JasonEstibeiro, first try: driver.find_element_by_xpath("//span[@class='ng-binding']").click() To make the options visible, and the click the option: driver.find_element_by_xpath("//li[@class='ng-scope'][9]").click() Commented Nov 4, 2015 at 11:13
  • Or this seems like a better option. Give it a try driver.find_element_by_xpath("//span[@class='ng-binding' and text()='Idea'][1]").click(). Let me know if any of them work. Commented Nov 4, 2015 at 11:22
  • Both options throw the same error: selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with Looks like first you have to unfold the options and afterwards select it. Commented Nov 4, 2015 at 11:32
  • @Javitronxo - Realized it now. I had actually manually clicked on it (the ng-binding span). Anyways, upvoted your answer. Commented Nov 4, 2015 at 12:12

3 Answers 3

4

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()
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks....it wroked...i have updated my question....n tried a lot to implement the same by refering the code you provided..."after selecting idea, i get a new drop down for select circle. Need to select Mumbai for it"....can you help plz
1

first click the select box then choose the option, to choose the vodafone you need to click 3rd child :

driver.find_element_by_css_selector(".select").click()
driver.find_element_by_css_selector(".options > ul:nth-child(1) > li:nth-child(3)").click()

other options are as the following:

.options > ul:nth-child(1) > li:nth-child(2) => Artiel
.options > ul:nth-child(1) > li:nth-child(3) => Vodafone
.options > ul:nth-child(1) > li:nth-child(4) => BSNL

after you select the first select box there are 2 select box, you can select it samely but by find_elements_by_css_selector() with pulural

# select first one
driver.find_element_by_css_selector(".select").click()
driver.find_element_by_css_selector(".options > ul:nth-child(1) > li:nth-child(3)").click()
# select second selectbox
# you may need to sleep until second selectbox is available
sleep(1)
driver.find_elements_by_css_selector(".select")[1].click()
driver.find_element_by_css_selector(".options.open > ul:nth-child(1) > li:nth-child(5)").click() # 5 option is Mumbai

1 Comment

Thanks....it worked...i have updated my question....n tried a lot to implement the same by refering the code you provided..."after selecting idea, i get a new drop down for select circle. Need to select Mumbai for it"....can you help plz
-1

floorselectionWait = WebDriverWait(driver,20).until(EC.presence_of_element_located((By.XPATH,'//*[@id="select_22"]'))) floorselection=driver.find_element(By.XPATH,'//*[@id="select_22"]') floorselection.click() flooroptionsWait = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,"//DIV[@class='md-text ng-binding'][text()='Level 7']"))) optionSelect=driver.find_element(By.XPATH,"//DIV[@class='md-text ng-binding'][text()='Level 7']") optionSelect.click() angularjs md-select md-option selecting in selenium python

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.