click() on css Selector not working in Selenium webdriver
i would inject piece of js to be confident in resolving this issue:
first of all locate element using DOM (verify in firebug):
public void jsClick(){ JavascriptExecutor js = (JavascriptExecutor) driver; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("document.getElementsByTagName('button')[0].click();"); js.executeScript(stringBuilder.toString()); }jsClick();
from the retrospective of your element it be like:
....stringBuilder.append("document.getElementsByTagName('input')[0].click();");....
Please, note: document.getElementsByTagName('input')
returns you an array of DOM elements. And indexing it properly e.g. document.getElementsByTagName('input')[0], document.getElementsByTagName('input')1, document.getElementsByTagName('input')[2]....,etc you will be able to locate your element.
Hope this helps you.Regards.
Please use the below code.
driver.findElement(By.cssSelector("input[value=\"Search\"]")).click();
It works for me. And make sure that the name is "Search", coz it is case sensitive.
Thanks
Are you sure that using this CSS-selector (input[value=Search]
) on your page you have only one result?