课程: Mobile Testing with Appium

今天就学习课程吧!

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

Waiting for elements: Practice

Waiting for elements: Practice

- [Instructor] Okay, let's see how to wait for elements in practice. First of all, I have my Appium server and my Android emulator up and running. So now let's go to our code editor. We're starting off here with the Ch_04_04_Waiting_For_Elements_Before.Java class. What we want to do initially is remove the Thread.sleep in the set-up method, and remove any extraneous lines in our test method. These two here, so that all we're doing is launching the app and finding an element using Driver.findElement. Okay, now let's run our test just to see what happens. The test is complete, let's head back to IntelliJ to see what happened and as predicted we got a failure. If we read the failure text, we will see that the issue is that an element couldn't be found. This is exactly the problem we expected, without the Thread.sleep protecting us our script tried to find the element before it was present. Now we can apply our WebDriverWait knowledge to fix the situation. So let's go ahead and update the…

内容