Locating an element using ng-model using Selenium in python

13,310

Since, this is an Angular application and python-selenium does not natively wait for Angular to "settle down" (as, for instance, protractor or pytractor), you need to explicitly wait for the element to become present:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
elm = wait.until(EC.presence_of_element_located((By.XPATH, "//select[@ng-model='yourName']")))

See also:

Share:
13,310
KingJames
Author by

KingJames

Updated on June 17, 2022

Comments

  • KingJames
    KingJames almost 2 years

    I am trying to automate an AngularJS application using Selenium in python. I am trying to find an element with ng-modal. I have seen some post related to Java which specifies that you can use the following statement

    "//input[@ng-model='yourName']"
    

    I am trying to do the same in python

    (By.XPATH, "//*/select[@ng-model='yourName']")
    

    But I am unable to find the element. Am I missing something or is there is some other way of doing it?