This is working for me using UI’s Select option. e.g.:

from import Select

driver = webdriver.Chrome()

# Locate the Sector and create a Select object
select_element = Select(driver.find_element_by_css_selector(".form-control"))
# this will print out strings available for  on select_element, used in visible text below
print [o.text for o in select_element.options]
# select by visible text
select_element.select_by_visible_text("Low Priority")
# or select by value
# or select by option index

Documentation here and some credit to Daniel Abel here.

I’m a bit concerned your error may be coming from somewhere else as the error you’re getting is selenium unable to find an element with the class of ng-valid, which isn’t included in your example selenium code. Also, with Angular be sure to throw in a wait for the angular page to load. Like:

from import WebDriverWait # Import at top of file
from import expected_conditions as EC

# Selenium waits for the page to load, but not necessarily the angular app
wait = WebDriverWait(driver, 10)

You may want to use protractor anyway as it has some custom locators for angular and will wait for ng-app to load by default.

Source link


Please enter your comment!
Please enter your name here