Search code examples
javaselectcolorsselenium-webdrivermouseevent

How to verify text color in selenium webdriver?


I have a web application.

Written automation script with selenium webdriver.

I have write some color code when I select some text.

Now I want to check that color is present or not.

How can I verify color code in selenium webdriver script?


Solution

  • After so many try with different script finally I am able to find my question`s answer.

    String colorString = driver.findElement(By.id("foo")).getAttribute("class");
    String[] arrColor = colorString .split("#");
    assertTrue(arrColor[1].equals("FFFFFF"));
    

    Thank You all for helping me.