How to Verify logo Color Size Font Height Width in Selenium webdriver
Example:
package colors;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class colorexp1 {
@Test
public void colorfonts()
{
WebDriver driver=new FirefoxDriver();
driver.get("https://www.google.co.in");
String color=driver.findElement(By.xpath("//* [@id='hplogo']")).getCssValue("color");
String bgcolor=driver.findElement(By.xpath("//*[@id='hplogo']")).getCssValue("background- color");
String font=driver.findElement(By.xpath("//*[@id='hplogo']")).getCssValue("font-style");
String fontsize=driver.findElement(By.xpath("//*[@id='hplogo']")).getCssValue("font-size");
int width=driver.findElement(By.xpath("//*[@id='hplogo']")).getSize().getWidth();
int height=driver.findElement(By.xpath("//*[@id='hplogo']")).getSize().getHeight();
System.out.println("colour: "+color);
System.out.println("Background color is:"+bgcolor);
System.out.println("Font is:"+font);
System.out.println("Font-size is:"+fontsize);
System.out.println("Width of logo is: "+width);
System.out.println("Height of logo is:"+height);
}
}
Output:
colour: rgba(34, 34, 34, 1)
Background color is:transparent
Font is:normal
Font-size is:13px
Width of logo is: 272
Height of logo is:92
PASSED: colorfonts
No comments:
Post a Comment