In this post, we will see How To Get Css Property Value in Selenium Webdriver Java | getCssValue() Command Selenium WebDriver
Program Code (GetCSSProperties.java):
package main;
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class GetCSSProperties {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver_win32\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://www.amazon.in/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
WebElement w=driver.findElement(By.xpath("//span[@id='glow-ingress-line2']"));
System.out.println(w.getCssValue("font-size"));
System.out.println(w.getCssValue("font-style"));
System.out.println(w.getCssValue("color"));
driver.quit();
}
}
Watch following video:
Watch on YouTube: https://www.youtube.com/watch?v=o-gkgK5aBRE
No comments:
Post a Comment