Home > Blockchain >  Make selenium Choose From the input box a number python
Make selenium Choose From the input box a number python

Time:10-13

I want Selenium to choose an option but it didn't work for me I tried this

phone = Select(driver.find_element(By.NAME, "PhoneCountry"))
phone.select_by_data-value(self, US)

and it failed

And this is the html

HTML of the page

CodePudding user response:

There is no such way to select option by_data-value.
There only 3 ways:

  1. Select by index
  2. Select by visible text
  3. Select by value.

References:
official documentations
www.geeksforgeeks.org

So, instead of your code please try this:

phone = Select(driver.find_element(By.NAME, "PhoneCountry"))
phone.select_by_visible_text(self, "US")

I don't know what is the actual visible text there, it can be "US", or "USA" or something else.

CodePudding user response:

I found the solution

Select(driver.find_element_by_id("PhoneCountry")).select_by_visible_text(u"United States ‏(‎ 1)")
  • Related