mihijs
mihijs

Reputation: 626

How to change value of css attribute with watir-webdriver after page is loaded?

Example:

<div id="xxx" style="width: 76px; height: 302px; z-index: 0; text-align: left;">

I would like watir-wedriver to change z-index: 0 to z-index: -1 automatically, otherwise I have to do that manually in Firebug while script is sleeping.

Upvotes: 2

Views: 2287

Answers (2)

mihijs
mihijs

Reputation: 626

Thanks, Željko, for idea!

The code that does the trick in this case is

browser.execute_script("document.getElementById('xxx').style.zIndex='-1';")

Upvotes: 3

Željko Filipin
Željko Filipin

Reputation: 57262

You can execute any javascript with something like this:

browser.execute_script "javascript_code"

I am not a javascript expert so you will have to figure out that part yourself.

Upvotes: 3

Related Questions