How do I get elements in Appium
In automation, element positioning is the first difficulty we encountered. There will always be various problems that result in our being unable to find items. The previous blog also wrote about various methods of element positioning. Today I am mainly going to share xpath's positioning method.
Here we take the calculator as an example.
For example, I want to find button number 1 here.
First open the UIuiautomatorviewer
We can see the location of this button by clicking the number 7 with the mouse. As mentioned in the previous article, in the element's attributes, class is the address of xpath, and we can write xpath through class.
Then we can write here:find_element_by_xpath ("// android.support.v4.view.ViewPager / android.widget.LinearLayout / android.widget.LinearLayout  /android.widget.Button ")
When you look here, it feels like peeling an onion. Peel layer by layer from the outside in and finally find the target we want to locate.
It should be noted here that we cannot start from the entire outermost side when finding it in xpath, which will lead to an error. What is the top-level element that the control contains to start writing from the top-level class that contains the control? For example the android.support.v4.view.ViewPager here, we can click on it to find
android.support.v4.view.ViewPager It's actually the entire keyboard area. Then reposition the number key 1 in the keyboard area.
And what I wrote above is android.widget.LinearLayout  /android.widget.Button  instead of android.widget.LinearLayout  /android.widget.Button  Looks like usUIuiautomatorviewerThe information received is not the same. Why is that? The author doesn't actually explain it clearly haha. I just think android.widget.LinearLayout  /android.widget.Button  is the third one to locate android.widget.LinearLayoutThe first one is inandroid.widget.ButtonElement. I remember in the book I saw that element positioning in xpath starts at 1 instead of 0, so I passed android.widget.LinearLayout  /android.widget.Button  go to control by number 1. What is being said here may be wrong. I am also looking for the answer and will update it when I find the answer.
Reprinted at: https://www.cnblogs.com/rookie-c/p/5886776.html
- Any Marine Haoshoku Haki can use it
- What do you need from Mongolia
- Which software companies have AGPL-licensed products?
- How long does a bladder loop last
- What is automation accounting software
- What are Cenforce Soft Pills
- What does a pianistic interpretation consist of
- Where can I download the film Tumbbad
- What forums do hackers follow
- How dangerous is a neutron star
- What are some pictures of actress Bhama
- How can you make someone snore
- Nietzsche studied semiotics
- What is the molecular geometry of NO3
- What is the microprolactinoma
- Can money buy you a family
- Migrating insects
- What should toddlers eat for breakfast?
- The employee compensation covers long-term injuries
- Why does glycerine act as a surfactant
- How bad is your friend
- When will Apple kill the iPhone
- What is digital life
- How can Wildfangjaeger be classified as LGBTQ
- What space technology is surprisingly old
- How can you treat partial dyslexia
- What does the nuclear half-life refer to?
- Have you seen La La Land
- Which is the most volatile halogen acid
- What causes itchy skin from sunburn
- Which picture makes you afraid?
- What are the best libraries in Gurgaon