Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of elements in Appium

Tags:

c#

xpath

appium

I am using appium and dot-net-driver.

Im trying to go thru all activity's of an app and get all the elements on every page.

but im unable to find the right way to get a list of all elements.

i tried to use c# regular expressions but with no luck.

if anyone have stumbled upon this issue and can help it will be much appreciated!

what i have tried to do:

     public void getElementToFile()
    {
        //var elementsList = driver.FindElementsByXPath("//android.widget");
        var elementsList = driver.FindElementsByClassName("android.widget");
        foreach(var element in elementsList){
            WritingText(element.Text);
        }

    }
like image 970
Matan Perry Avatar asked Dec 08 '15 12:12

Matan Perry


People also ask

How do I get a list of elements in Appium?

Use the UI Automator API, in particular the UiSelector class to locate elements. In Appium you send the Java code, as a string, to the server, which executes it in the application's environment, returning the element or elements.

What is the use of find elements method in Appium test script?

When using Appium findElement by XPath, the program analyzes the XML structure of the app and locates a particular element relative to other elements. In fact, originally this strategy was developed to navigate XML data in order to locate unique UI elements. Remember that XPath selectors are not cross-platform.

How do I find my element ID in Appium?

In the Appium version 1.0 onwards, findElementByTagName is deprecated. Show activity on this post. You can find the ID of an element using android uiautomatorviewer. just go to your SDK tools folder D:\Android\android-sdk\tools, here you can find uiautomatorviewer.


1 Answers

   var elementsList = driver.FindElementsByXPath("//*");

Btw i must warn that you shouldnt do this because it will not be efficient at all. You need to use specific xpaths and ID's for any automation. And this has nothing to do with your Language or driver.

like image 71
Shamik Avatar answered Sep 20 '22 23:09

Shamik