I am working in appium and My app is a hybrid app it is coded with angular js.

I have scenario to automate. A page opens liks select date -> today, tomorrow and pick a date

<div class="item item-divider">
                <p>Select Date</p>
<button class="button button-block button-light">Today</button>

<button class="button button-block button-light">Tomorrow</button>

<button class="button button-block button-light">Pick a date</button>

If I enter the date today How to automate this ?

enter image description here

  • Hi @comrade can you please add a screenshot of the screen and some more HTML for finding out the element. – Jeevan Bhushetty Mar 24 '17 at 9:12
  • @Antony did you manage to resolve this problem? – Piotr Wicherski Aug 22 '17 at 19:39

You are getting this because of the classname used. Try the code below to get all textviews elements

List<WebElement> textViews = driver.findElements(By.Xpath("//*[conatains(@class,'button-block'));

for (WebElement textView : textViews)

    System.out.println( textView.getText());
| improve this answer | |

Another alternative would be to find elements by class name and then iterate through the list. You may do something like this

boolean todaysDateFound = false;

List <WebElement> days = DRIVER.findElements(By.className("button button-block button-light"));

    for (int i = 0; i < days.size(); i++) {
            if (days.get(i).getAttribute("name").equals("Today")) {
                todaysDateFound = true;

If you want to make this smarter and decide what to pick based on user input, then you can use a Select..Case statement as well


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy