cisco-open-source / qtwebdriver

WebDriver implementation for Qt
https://github.com/cisco-open-source/qtwebdriver/wiki
197 stars 59 forks source link

Wait for qml animations #58

Open Zitrax opened 7 years ago

Zitrax commented 7 years ago

I am evaluating qtwebdriver for use with our qml project, and I have built it and gotten simple test cases to work. I am using python selenium at the moment.

However we have some transition animations and I have not found how to properly wait for them (except an ugly and not optimal time.sleep() ). I have tried the existing wait conditions such as visibiliy_of_element_located and element_to_be_clickable but they both trigger before the animation is done.

Do I need some custom wait condition to handle this, or is there some other known way to deal with this? Or possibly some known limitations or issues? Any pointer would be helpful.

hekra01 commented 7 years ago

Maybe trying with selenium JS injection, and some qml features of QtWebdriver

1-From selenium you can locate a qml element by id see https://github.com/cisco-open-source/qtwebdriver/wiki/QML-Specifics if you define "objectName" of element to locate

2-Use 1) to locate your qml animation

3-Then use Selenium javascript inject to interact with qml element, e.g: query get animation "running" status

isRunning = webdriver.execute_script("var v = ObjectNameUtils.findChild('animationId'); return v.running;")

4-Refactor previous in a method in your selenium test, e.g

public void waitForAnim(String animID) {
// locate anim
// While (anim.running) sleep (1s) 
}