Android : How to set a date of an html5 datepicker using appium in android?

on Monday, September 29, 2014


I'm trying to create automated tests for a hybrid app which has an html5 date input type. I'm using Appium in combination with robot framework (python) and I try to use the Appium library for the robot framework as much as possible.


For some reason I can't set the date of the datepicker. I've tried a couple of different things:



  • Using input text (send keys) on the datepicker input

  • Clicking on the datepicker so it opens up the popup date selector And then trying to set the individual fields using different locators such as:


Name (The name changes once you send a key to the field which causes the next i've tried:



name=Sep


But when i try to put in Jan it stops after the J has been entered.


Xpath (for some reason this returns all fields where it should only return 1 field) i've tried the following xpath locators:



//android.widget.DatePicker//android.widget.LinearLayout[1]/android.widget.EditText
//android.widget.DatePicker//android.widget.ImageButton[@content-desc="Increase month"/../android.widget.EditText


this is the structure of the datepicker



Datepicker
LinearLayout
LinearLayout
LinearLayout
ImageButton {increase month}
EditText:Sep
ImageButton {decrease month}
LinearLayout
ImageButton {increase day}
EditText:29
ImageButton {decrease day}
LinearLayout
ImageButton {increase year}
EditText:2014
ImageButton {decrease year}


I can't think of anything else to do to set the date of the datepicker. Is there an easy way to set the date for the html5 datepicker?


0 comments:

Post a Comment