angularjs - angular UI bootstrap datepicker can't get value using JQuery expression -
i'm using datepicker angular ui bootstrap lib. https://angular-ui.github.io/bootstrap/#/datepicker
after select date, i'm not able text of input using jquery expression. $('#effectivedate').text() returning empty, can see has value on page.
what can retrieve value?
updates: in chrome console,
$('#effectivedate') returns:
[<input id="effectivedate" name="effectivedate" type="text" class="form-control pickdaterinput ng-valid ng-isolate-scope ng-valid-date ng-dirty ng-valid-parse ng-touched" datepicker-popup="dd-mmmm-yyyy" ng-model="elt.registrationstate.effectivedate" is-open="opened" min-date="mindate" datepicker-options="dateoptions" close-text="close">] $('#effectivedate').text(); returns;
"" angular.element($0).scope().elt.registrationstate.effectivedate returns:
tue jul 14 2015 00:00:00 gmt-0400 (eastern daylight time) but in selenium:
javascriptexecutor js = (javascriptexecutor) driver; string effectivedate_string = js.executescript("angular.element($0).scope().elt.registrationstate.effectivedate.gettime().tostring()").tostring(); gives error:
org.openqa.selenium.webdriverexception: unknown error: $0 not defined (session info: chrome=43.0.2357.132) (driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=windows nt 6.1 sp1 x86_64) (warning: server did not provide stacktrace information) command duration or timeout: 9 milliseconds
did try clicking on actual input element in chrome (firefox) , typing in console?
angular.element($0).val() also, did try this
$('#effectivedate').val() instead of this
$('#effectivedate').text() update
regarding comment
this $('#effectivedate') returns: []
$('#effectivedate')[0].val() the reason when calling $('#effectivedate') getting array 1 value care about, means have first item of array, [0]. may try more readability.
$('#effectivedate').first().val();
Comments
Post a Comment