Nilophar
Nilophar

Reputation: 51

How to count number of elements pressent on screen

In my application i wanna count number of elements pressent in on div using appium 1.7.1 for ios
Example in my application room wise i wanna count in one room how many switches are pressent

Upvotes: 1

Views: 1948

Answers (2)

Nilophar
Nilophar

Reputation: 51

I can able to count number of switches in one room.. Below code is working fine for me

TouchAction touch1 = new TouchAction(driver);

touch1.tap (80, 300).perform();

List optionCount =driver.findElementsByClassName("XCUIElementTypeImage");

System.out.println(optionCount.size()-1); Blockquote

Upvotes: 1

Mike Collins
Mike Collins

Reputation: 4559

You're going to want to use findElements, which will you return you a list of all elements matching your query. You'll then use standard Java to grab the number of elements in the list.

Usage examples: http://toolsqa.com/selenium-webdriver/findelement-and-findelements-command/

Upvotes: 0

Related Questions