0% found this document useful (0 votes)
8 views3 pages

Selenium Exercise 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Selenium Exercise 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Exercise 1:

package automation_testing;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

public class Exercise1

public static void main(String[] args) throws InterruptedException

System.setProperty("webdriver.chrome.driver", "C:\\Users\\omkar\\OneDrive\\Documents\\
Selenium\\chromedriver-win64\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.get("https://web-locators-static-site-qa.vercel.app/Button");

driver.manage().window().maximize();

Thread.sleep(2000);

WebElement clickButton = driver.findElement(By.xpath("//*[@class=\"buttonContent\"]"));

System.out.println("Button is displayed");

Thread.sleep(2000);

boolean isDisplayed = clickButton.isDisplayed();

if (isDisplayed)

{
System.out.println("Button is Enabled");

Thread.sleep(2000);

boolean isEnabled = clickButton.isEnabled();

if (isEnabled)

clickButton.click();

System.out.println("Button is Clicked");

Thread.sleep(2000);

else

System.out.println("The button is not enabled.");

else

System.out.println("The button is not displayed.");

driver.close();

Output:

You might also like