Interview Questions

Selenium WebDriver - How to check if a text is highlighted on the page ?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

Selenium WebDriver - How to check if a text is highlighted on the page ?

To identify weather color for a field is different or not- String color = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("color");
String backcolor = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("background-color"); System.out.println(color); System.out.println(backcolor);
String color = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("color");
String backcolor = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("background-color");
System.out.println(color);
System.out.println(backcolor);
Here if both color and back color different then that means that element is in different color.

(Continued on next question...)

Other Interview Questions