I grabbed this element using selenium webDrive:
<div class="body" style="background-image: url('http://d1oiazdc2hzjcz.cloudfront.net/promotions/precious/2x/p_619_o_6042_precious_image_1419849753.png');">
how can I fetch the value: http://d1oiazdc2hzjcz.cloudfront.net/promotions/precious/2x/p_619_o_6042_precious_image_1419849753.png ?
I'm not sure as this is an inner value, and not just an "src" attribute.
getCssValue(); will help you
WebElement img = driver.findElement(By.className('body'));
String imgpath = img.getCssValue("background-image");
then you can split the unwanted string "url('"
PS : Remove the javascript tag in your question
Try this
var imgString = $(".body").css('background-image');
console.log (imgString.split("(")[1] // remove open bracket
.split(")")[0] // remove close bracket
);
Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With