5

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?

1 Answer 1

3

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:

Sign up to request clarification or add additional context in comments.

2 Comments

Apart from EC.presence_of_element_located, sometimes the element is not yet visible to the user to be interactable, in which case it's better to use EC.visibility_of_element_located
i tried the above code but its not working. nothing happens.i tried both EC.presence and EC.presence.

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.