我有一個div,其高度非常小。我無法訪問位於div底部的一些子元素。我試圖使用 element .elements.last.wd.location_once_scrolled_into_view
滾動,但我無法滾動它。如何在運行時使用watirwebdriver更改div的Style屬性
然後我試着看看是否可以增加div的高度,以便腳本可以查看所有節點。原來的風格是style = 'overflow-y:auto;overflow-x:auto;width:150px;height: 350px;
的代碼我使用的修改是
element = @browser.div(:id => 'div:d')
puts element.attribute_value('style')
script = "return arguments[0].style = 'overflow-y:auto;overflow-x:auto;width:150px;height: 750px; '"
@browser.execute_script(script, element)
puts "edited height"
puts element.attribute_value('style')
我仍然看到風格值overflow-y:auto;overflow-x:auto;width:150px;height: 350px;
。 運行時不能編輯div的高度嗎?
'script =「arguments [0] .style.height ='750px';」 '工作得很好〜!非常感謝! – mkum