Help, please,to correctly write a test of datepicker. I have an unclickable field where my selected date will be set:
<input type="text" class="submit hasDatepicker" placeholder="License Expiry Date*"
name="website_field[bGl==]"
id="website_field_bGl" value="" size="16"
readonly="readonly">
with clickable button that opens a date-form:
<img class="ui-datepicker-trigger" src="images/calendar.png" alt="Select date"
title="Select date">
month:
<select class="ui-datepicker-month" data-handler="selectMonth" data-
event="change"><option value="0">Jan</option></select> ...
year:
<select class="ui-datepicker-year" data-handler="selectYear" data-
event="change"><option value="2000">2000</option></select> ...
and a script:
$(function(){
$( "#website_field_bGljZW5zZSBleHBpcnkgZGF0ZQ"
).datepicker({
changeMonth: true,
changeYear: true,
firstDay:1,
dateFormat: "yy-mm-dd",
showOn: "button",
buttonImage: "images/calendar.png",
buttonImageOnly: true,
buttonText: "Select date",
minDate: "2000-01-01",
yearRange: "2000:+15"
}).attr("readonly", "readonly");
});
I need to set a date, for example: 2020-07-14.
How to do this? Thanks.
I did smth primitive and it works. But maybe there is more 'pro' variant available?:
var LicenceExpiryDateInputField =
element(by.id('website_field_bGljZW5zZSBleHBpcnkgZGF0ZQ'));
var LicenceExpiryDateButton = $('img.ui-datepicker-trigger');
var LicenceExpiryDateForm = element(by.id('ui-datepicker-div'));
var SelectMonth = $('select.ui-datepicker-month').$('[value="6"]');
var SelectYear = $('select.ui-datepicker-year').$('[value="2020"]');
var SelectDate = element(by.linkText('14'));
LicenceExpiryDateButton.click();
expect(LicenceExpiryDateForm.isPresent()).toBe(true);
SelectMonth.click();
expect(SelectMonth.isSelected()).toBe(true);
expect(SelectMonth.getText()).toEqual('Jul');
SelectYear.click();
expect(SelectYear.isSelected()).toBe(true);
expect(SelectYear.getText()).toBe('2020');
SelectDate.click();
expect(...Here i need to check somehow LicenceExpiryDateInputField on correct data (2020-07-14)...)