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.
我希望watir-wedriver能够自动将z-index: 0更改为z-index: -1,否则在脚本休眠时,我必须在Firebug中手动更改。
2 个解决方案
#1
3
You can execute any javascript with something like this:
你可以用这样的方式来执行任何javascript:
browser.execute_script "javascript_code"
I am not a javascript expert so you will have to figure out that part yourself.
我不是javascript专家,所以您必须自己解决这个问题。
#2
3
Thanks, Željko, for idea!
谢谢,Željko,主意!
The code that does the trick in this case is
在这种情况下起作用的代码是
browser.execute_script("document.getElementById('xxx').style.zIndex='-1';")
#1
3
You can execute any javascript with something like this:
你可以用这样的方式来执行任何javascript:
browser.execute_script "javascript_code"
I am not a javascript expert so you will have to figure out that part yourself.
我不是javascript专家,所以您必须自己解决这个问题。
#2
3
Thanks, Željko, for idea!
谢谢,Željko,主意!
The code that does the trick in this case is
在这种情况下起作用的代码是
browser.execute_script("document.getElementById('xxx').style.zIndex='-1';")