Selenium | Unable to find Command button using Selenium Webdriver

|
| By Webner

Problem: Unable to find the Command button using Selenium Webdriver.

Solution: You can use following script code if you want to find command button on a web page and then click it:

driver.findElement(By.xpath("//button[text()='(Button name)']")).click();

Here is the script which we used in Webdriver:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Start
{
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://tarjetasvirtuales.com/view/index.php");
driver.findElement(By.xpath("//button[text()='Ver Encuesta']")).click();
driver.quit();
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *