0

Got this:

<div class="photo" style="background-image: url("my-url.jpg");">   </div>

I have tryed this, but get an error:

javascript{window.document.getElementsByClassName('photo').getPropertyValue('background-image')}

I want to store "my-url.jpg" with selenium ide, so the value of background-image style, and my element has no id. anyone have a solution?

2 Answers 2

1

Java version. driver.findElement(By.cssSelector("your selector")).getAttribute("style");

Sign up to request clarification or add additional context in comments.

4 Comments

I'm not sure it will help, because you use selenium driver syntax, and i'm using selenium ide only in my browser.
When you record your can save as a particular language, like Java. Save it, then find where you'd like to get the style. Add some logging msg there and output what you get for style to confirm you got it right.
but how do i run it? do i have to install eclipse and jUnit? i was looking for a "native" command in html...
Just play it back in the ide recorder tool
0

I have found a solution to extract image Url:

<tr>
    <td>storeAttribute</td>
    <td>css=div.photo@style</td>
    <td>image_style</td>
</tr>
<tr>
    <td>storeExpression</td>
    <td>javascript{storedVars['image_style'].split('(&quot;')[1]}</td>
    <td>image_url</td>
</tr>
<tr>
    <td>storeExpression</td>
    <td>javascript{storedVars['image_url'].split('&quot;)')[0]}</td>
    <td>image_url</td>
</tr>

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.