Handling Image:
Common Actions:
- Click the Image
- Get the 'src' Attribute of the Image
- Check if the Image is Displayed
- Check if the Image is Enabled
- Get the Alt Text of the Image
package
WebelementsBasics;
import
org.openqa.selenium.By;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
public
class ImageBasics {
public static void main(String[]
args) throws InterruptedException {
//open chrome browser
System.setProperty("webdriver.chrome.driver",
".\\Drivers\\chromedriver.exe");
WebDriver driver =
new ChromeDriver();
Thread.sleep(3000);
driver.navigate().to("file:///C:/brahma/Practise/qtp%20practise/web%20apps/ALL%20Web%20objects.html");
// check 'Penguins' Image is displayed by id
boolean
imgDisplayed =
driver.findElement(By.name("myimage")).isDisplayed();
// true
//
String, int, boolean
System.out.println("isDisplayed="+imgDisplayed);
//
isDisplayed= true
//HW
get 'width' attribute value for image ?
//HW
get 'height' attribute value for image ?
//HW
get 'alt ' attribute value for image ?
// alt = alternate text
//
HW get 'src' attribute value for image ?
// dont have
name , id , class --- > xpath,
cssSelector
}
}
No comments:
Post a Comment