Interview Questions

Selenium WebDriver - How to check whether a text is underlined or not ?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

Selenium WebDriver - How to check whether a text is underlined or not ?

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(); } }

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();
}

}

(Continued on next question...)

Other Interview Questions