The mobile app is depicted in the leftmost pane and when clicking an element we see the attributes in the rightmost pane.įinding an element using Class Name is generic and it does not guarantee to find the unique element because many elements have the same class name. The screenshots that follow are using this Inspector to illustrate the locator. We will learn about that tool in the next chapter. NOTE: All of the above Locator Strategies can be inspected using the Appium Inspector Tool (for Android and iOS both). When that happens, refer back to these different locator strategies to see which might best fit your needs. In fact, there are some tricks coming up later that will automatically suggest which strategy to use! Often during your script development you’ll wrestle with trying to identify a UI element. Don’t worry about memorizing all of them … at this stage in your journey you just need to become familiar with them and eventually you’ll understand which are best to use in which scenarios. We will go through all Locator Strategies and discuss them in detail. Learning which type of Locator Strategy to use is part of the learning process of becoming comfortable with Appium. If you recall our simple test cases in Chapter 2, our Appium Android example used the following code for identifying the Textview: Appium makes many different strategies available. The way in which you uniquely identify the element is called a locator strategy. As you will see, sometimes this is easy, and other times you have to do some further exploration to uniquely identify your UI element. This means that we need to find a unique address for the element. As there are many UI elements present on a single mobile application screen there can be a chance that same (generic)address can refer to more than one element. So What is an Element Locator? An Element Locator is nothing but an address that identifies a UI Element on a Mobile App (or Website). In this chapter we focus on the first step and will look into all the available Locator Finding Strategies and discuss each strategy’s pros and cons. In Mobile (or Web) Automation Testing automating any scenario follows these 2 steps: After all, if you’re unable to “find” the UI element, you cannot control it (such as clicking a button). Understanding how to properly use Locators is key to building your automation scripts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |