Reputation: 475
WebDriver->I am trying to capture the 'date' selected from a UI-Calender. I want to find the 'date' element selected using javascript.For which I used the following :
WebElement element = (WebElement) ((JavascriptExecutor)driver).executeScript("return $('#abc')");
String s=element.getAttribute("value");
System.out.println(" "+s);
But strangely when I add the above lines, Firefox stops responding, then script stops working .Version firefox:3.6
Upvotes: 2
Views: 3706
Reputation: 4073
That's because return $('#abc')
returns an array of DOM elements. You should use return $('#abc')[0]
.
WebElement element = (WebElement) ((JavascriptExecutor)driver).executeScript("return $('#abc')[0]");
Upvotes: 3