I have submit button, which is only one on the page, and it\'s in form.
html part:
The method object.submit()
is there for submitting the form to the server. It has another advantage, in case if you're not able to locate the "submit" button then you can take any object of the form and trigger submit() function.
It seems in searchButton.submit();
searchButton is an element of the form and the submit action on it triggers submission of form on server.
Now, why searchButton.click();
not working here could have following reasons.
searchButton
element.Suggestion: Evaluate following code and check it returns more than one element. If it does then you're clicking on the wrong instance.
List e = driver.findElements(By.xpath("//button[@type='submit']"));
Also try,
driver.findElement(By.xpath(".//button[@class='btn btn__primary'][@type='submit']")).click()
http://docs.seleniumhq.org/docs/03_webdriver.jsp#user-input-filling-in-forms