简体   繁体   English

如何在 selenium 中使用 java 单击提交按钮?

[英]How to Click on Submit button using java in selenium?

want to click on button search...?想要点击按钮搜索...?

<button class="btn btn-info btn-sm" type="submit">
    <i class="fa fa-search">&nbsp;</i>
    Search 
</button>

if you use google chrome web driver you can try following way.如果您使用 google chrome 网络驱动程序,您可以尝试以下方式。

you can use the the class name of the button or xpath of the button.您可以使用按钮的类名或按钮的 xpath。

    WebDriver driver;

    System.setProperty("webdriver.chrome.driver","");
    driver = new ChromeDriver();

the way to use class name of button按钮类名的使用方式

    driver.findElement(By.className("include class name of    button")).click();

the way to use the xpath of the button按钮xpath的使用方式

    driver.findElement(By.xpath("include xpath")).click();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM