课程: Mobile Testing with Appium

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Waiting for elements: Theory

Waiting for elements: Theory

- [Instructor] Now that we know how to find elements in Appium, it's important to learn how to find elements at the right time. The code that we've been writing so far looks similar to what I have on screen now. We start our Appium session. Then we wait for three seconds using thread.sleep. Then in our test method we find the login screen element. The reason we have thread.sleep here is that without it our element might not be found. Whenever we call driver.findelement, Appium will look to see if it can find the element at exactly that time. Appium is not super smart and doesn't know what's going on in the app. So it doesn't know if it should wait for the app to load or for something else to happen before it tries to find the element. A human user would, of course, notice that the app is still loading and not try and tap any buttons. But Appium is not yet that intelligent, so we have to make sure to build that intelligence into our test scripts. One strategy is to do what we're…

内容