1

CSS style sheet:

background: url("/olam/images/brand30/usage_meter/green-vertical.png") repeat-x scroll 0 0 rgba(0, 0, 0, 0);

I want to retrieve the URL, tried using below :

String cssValue = driver.findelement(by.xpath).getCssValue("background");
System.out.println(driver.findelement(by.xpath).getCssValue("background"));

Still unable to retrieve the background value, i am getting Null value.

  • Do you have the page link? Will try to write it up then. – FDM Feb 17 '15 at 14:22
1

background is a shorthand property. It's really just a convenient way of writing a bunch of real properties.

According to the JavaDoc, getCssValue() cannot retrieve shorthand properties. you have to ask for the individual properties, like background-image and background-color.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.