1

Below is the code, trying to find the colour of the text 'Special Assistance' in spicejet.com. I am expecting rgb value as (196,18,48) (as shown in the developer view during inspection of the element) however when i run the program it displays value as rgba (0,0,0,1);

    driver.get("https://www.spicejet.com");
    driver.manage().window().maximize();
    WebElement ele = driver.findElement(By.xpath("//a[text()='Special Assistance']"));
    System.out.println(ele.getCssValue("color"));

please help

  • You might find [this](https://stackoverflow.com/questions/32537339/getting-the-values-of-all-the-css-properties-of-a-selected-element-in-selenium) useful. – Syed Azeem Javed Nov 18 '20 at 16:38
  • Weird. I get three values when I try the same thing: rgba(0, 0, 0, 1), rgba(196, 18, 48, 1) and rgba(60, 60, 60, 1). I'm not using Java though, could println truncate it after the first line instead of outputting all the responses? – PMental Nov 18 '20 at 18:39
  • Please consider ticking as correct the answer which does what you want. – keepAlive Dec 01 '20 at 16:49

1 Answers1

0

That page looks like it has multiple elements that match that xpath. As such I think you're getting the wrong one returned and the color is actually correct.

If you're actually looking for the red special assistance link this might be a better (more specific) xpath:

//*[@id='discount-checkbox']//a[text()='Special Assistance']

Try that, and I think you may find the expected results.

DMart
  • 2,401
  • 1
  • 14
  • 19