limited time offer

What are the multiple ways to click on Submit button in Selenium?

Here are the list of techniques:

.click() method: You can use .click() method to click on any button of software web application. Means element's type = "button" or type = "submit", .click() method will works for both.

WebElement myButton = driver.findElement(By.cssSelector("locator"));
myButton.click();

.submit() method: If you will look at firebug view for any form's submit button then always It's type will be "submit". In this case, .submit() method Is very good alternative of .click() method.

WebElement myButton = driver.findElement(By.cssSelector("locator"));
myButton.submit();

Keys.Enter: 

WebElement myButton = driver.findElement(By.cssSelector("locator"));
myButton.sendKeys(Keys.ENTER);

Action Class:

WebElement myButton = driver.findElement(By.cssSelector(locator));
Actions builder = new Actions(driver);
    builder
        .moveToElement(myButton)
        .click()
        .build()
        .perform();

JavaScriptExecutor:

WebElement myButton = driver.findElement(By.cssSelector(locator));
JavascriptExecutor js = (JavascriptExecutor)driver;		
js.executeScript("arguments[0].click();", myButton);