Handling Buttons

Manual actions on button

  • Click
  • Check for enabled status
  • Get button text
  • Check display status

Selenium WebDriver Steps

package HandlingElementsInSelenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class HandlingButton {

	public static void main(String[] args) {
	System.setProperty("webdriver.chrome.driver", "F:\\chromedriver.exe");
		WebDriver driver = new ChromeDriver();
		driver.manage().window().maximize();
		driver.get("https://accounts.google.com/signin/v2/identifier?continue");
		
		WebElement button = driver.findElement(By.id("identifierNext"));

		//Display Status
		boolean status = button.isDisplayed();
		System.out.println("Button is displayed :- "+status);
		
		//Enable status
		status = button.isEnabled();
		System.out.println("Button is enabled :- "+status);
		
		//Get Button text
		String buttonName = button.getText();
		System.out.println("Button name is :- "+buttonName);
		
		//Click
		button.click();
		driver.close();
       }
}

Next

Leave a comment

Design a site like this with WordPress.com
Get started