Sunday 26 July 2015

How to check whether a text is underlined or not ?

Ans- Identify by getCssValue(“border-bottom”) or sometime getCssValue(“text-decoration”) method if the

 cssValue is 'underline' for that WebElement or not.

 ex- This is for when moving cursor over element that is going to be underlined or not-

 public class UnderLine {

 public static void main(String[] args) {

 WebDriver driver = new FirefoxDriver();

 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

 driver.get("https://www.google.co.in/?gfe_rd=ctrl&ei=bXAwU8jYN4W6iAf8zIDgDA&gws_rd=cr");

 String cssValue= driver.findElement(By.xpath("//a[text()='Hindi']")).getCssValue("text-decoration");

 System.out.println("value"+cssValue);

 Actions act = new Actions(driver);

 act.moveToElement(driver.findElement(By.xpath("//a[text()='Hindi']"))).perform();

 String cssValue1= driver.findElement(By.xpath("//a[text()='Hindi']")).getCssValue("text-decoration");

 System.out.println("value over"+cssValue1);

 driver.close();

 }

 }

1 comment:

  1. what will be the output n how u r handling in assertion?

    ReplyDelete