jeudi 1 janvier 2015

Expected conditions in protractor

While writing selenium tests in Python, I got used to using Explicit Waits a lot for waiting for a page to load, or for waiting for an element to become visible, or clickable etc:



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

element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "myDynamicElement"))
)


The key concept here is providing an Expected Condition to wait for, there are multiple types:



Using Expected Conditions make the code cleaner and more reliable comparing to using sleeps with hardcoded time intervals.


Now, we are switching our end-to-end testing infrastructure to protractor a lot.


Are there similar Expected Conditions in protractor as there are in python-selenium or java-selenium ? If not, what is the canonical way to explicitly wait for a condition in protractor?


I've looked through protractor documentation and found nothing about it.


Aucun commentaire:

Enregistrer un commentaire