Reputation: 15002
I want to set the date value by selenium.
Which is a datapicker element with disabled attribute
This script doesn't work for me
@driver.execute_script("document.getElementById('departureDate').setAttribute('value', '2015-09-07')")
I even couldn't get value by this @driver.execute_script("document.getElementById('departureDate').getAttribute('value')")
However I can get inspect the value by
[50] pry(#<Tiger>)> el = @driver.find_element(:id, "departureDate")
#<Selenium::WebDriver::Element:0x3f5415a2252a05c4 id="{f12a4095-6326-d241-b22d-aca9c03918e3}">
[51] pry(#<Tiger>)> el.attribute("value")
"2015-09-18"
But how can I set the value with 2015-09-07
I'm working on this page https://m.tigerair.com/booking/search
Upvotes: 0
Views: 1883
Reputation: 9568
Use querySelector() by supplying css path to get tag information, and then add this js-code to selenium as a string.
var taginfo = document.querySelector('input#departureDate');
var date = taginfo.value;
console.log(date);
to change try this.
taginfo.value.replace('2015-09-08');
Upvotes: 1