1

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? – Helping Hands May 28 '15 at 7:29
  • Logo background image url , but that is defined in the class "title" in a seperate css file – QAMember May 28 '15 at 7:33
  • Yes but which css property it is using for background? background OR background-image – Helping Hands May 28 '15 at 7:33
  • css property name is :: background – QAMember May 28 '15 at 7:42
  • ok kindly check my answer..Hope that help. – Helping Hands May 28 '15 at 7:51
2

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

Example:

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

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 ...:) – Helping Hands May 28 '15 at 10:42

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.