0% found this document useful (0 votes)
20 views

Selenium Exercise 3

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Selenium Exercise 3

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Exercise 3:

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 Exercise3

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/Image");

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

WebElement twoEyesImage = driver.findElement(By.xpath("//img[@alt=\"image_screen\"]"));

Thread.sleep(2000);

boolean isDisplayed = twoEyesImage.isDisplayed();


if (isDisplayed)

String srcValue = twoEyesImage.getAttribute("src");

String altValue = twoEyesImage.getAttribute("alt");

System.out.println("Image src: " + srcValue);

System.out.println("Image alt: " + altValue);

else

System.out.println("The 'two eyes' image is not displayed.");

driver.close();

}
Output:

You might also like