[英]Rspec and Watir; use array param as for an element index
使用Rspec運行GUI測試。 我是否可以傳遞值的數組並將其用作元素的索引位置?
就像是:
def pin_specific_idxs(*idx)
pins = foo.divs(:class => 'some-element', :index => idx).div(:class, 'another-element').button(:class, 'thingy-i-want-to-click')
pins.each do |pin|
pin.click
end
end
因此,在測試中,我將調用pin_specific_idxs(0,2,3)
那可行嗎,還是我每次都必須顯式調用單個索引值?
您需要做兩件事:
:index
:index
找到特定的div
而不是divs
(即元素集合不支持:index
定位器) 看起來像:
def pin_specific_idxs(*idxs)
idxs.each do |idx|
foo.div(:class => 'some-element', :index => idx)
.div(:class, 'another-element')
.button(:class, 'thingy-i-want-to-click')
.click
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.