Reputation: 67
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);
}
}
Upvotes: 5
Views: 20633
Reputation: 1790
Sometimes i also faced similar issue when i find by class name. so i used xpath and it always worked. Below is code snippet in java
List<MobileElement> allCheckBoxes=driver.findElementsByXPath("//*[@class='android.widget.CheckBox']");
for (MobileElement mobileElement : allCheckBoxes) {
System.out.println(mobileElement.getText());
}
Upvotes: 1
Reputation: 1609
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.
Upvotes: 6
Reputation: 67
I was able to find all elements on the page using the following line.
I Guess the dot-net-driver support of Regax excpressions is limited. @Shekhar Swami, thanks, your answer was a guidline!
Find all element on current activity using Appium and dot-net-driver:
IList<AppiumWebElement> els6 = driver.FindElementsByXPath("//*");
Upvotes: 0