So i have a datepicker field with a unique name and an input field before that one which has no unique identifiers. Since handling datepickers with custom keywords seems kinda complicated, i want to locate that input field relative to the datepicker and set the text for the date:
Script
WebElement date1 = driver.findElements(By.xpath(’//input[@name=“B3802”]/preceding-sibling::input[@placeholder=“TT.MM.JJJJ”]’))
date1.sendKeys(“10.10.2018”)
HTML
<input type="text" placeholder="TT.MM.JJJJ" value="">
<input type="date"
name="B3802" placeholder="TT.MM.JJJJ" required="" data-datepicker="true"
data-message-valuemissing="Please enter date.">
</span>
Error:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object