未使用selenium java单击按钮

未使用selenium java单击按钮,java,selenium-webdriver,eclipse-mars,Java,Selenium Webdriver,Eclipse Mars,我正在尝试编写登录脚本。。发送键正在工作 但是按钮没有被点击 以下是HTML代码: <div style="text-align: right"> <button id="btnLogin" class="btn btn-wide btn-success col-xs-offset-6"style="width: 85px; font-weight: bold; margin-left: 0px" type="submit"> Sign In</button

我正在尝试编写登录脚本。。发送键正在工作 但是按钮没有被点击

以下是HTML代码:

<div style="text-align: right">
    <button id="btnLogin" class="btn btn-wide btn-success col-xs-offset-6"style="width: 85px; font-weight: bold; margin-left: 0px" type="submit"> Sign In</button>
</div>

如果您没有遇到任何异常,您可以尝试driver.findElement(By.id(“btnLogin”)).sendKeys(Keys.RETURN);谢谢你。。适合我。如果你没有得到任何异常,你可以尝试driver.findElement(By.id(“btnLogin”)).sendKeys(Keys.RETURN);谢谢你。。对我有用。
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.By.ByTagName;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;  

public class Main {
    public static void main(String[] args) 
    {
        WebDriver driver=new FirefoxDriver();
        driver.get("here is my url");

        driver.findElement(By.id("UserName")).sendKeys("dishashah");
        driver.findElement(By.id("Password")).sendKeys("disha1234");
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

        driver.findElement(By.id("btnLogin")).click();
    }
}