I want to get the background image url which is defined in a css class . Is it possible to do by using selenium webdriver

Example :

Sample Text with Logo

Now I want to achevie the logo url but that url is defined in the title class. If any solved these type of issues please let me know

  • you want to get logo URL OR logo background image URL? May 28, 2015 at 7:29
  • Logo background image url , but that is defined in the class "title" in a seperate css file
    – QAMember
    May 28, 2015 at 7:33
  • Yes but which css property it is using for background? background OR background-image May 28, 2015 at 7:33
  • css property name is :: background
    – QAMember
    May 28, 2015 at 7:42
  • ok kindly check my answer..Hope that help. May 28, 2015 at 7:51

1 Answer 1


You can get property background URL by following code .getCssValue("background")


WebDriver driver = new FirefoxDriver();
driver.get("your site URL");
String url = driver.findElement(By.Xpath("//path")).getCssValue("background")

Above will print background Image URL as per your need. Please replace actual URL and your title div xpath in above code.

  • Great..cheers..:) Any time I am here to help ...:) May 28, 2015 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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