Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 如何使用水豚进行动态标签?_Ruby_Capybara - Fatal编程技术网

Ruby 如何使用水豚进行动态标签?

Ruby 如何使用水豚进行动态标签?,ruby,capybara,Ruby,Capybara,我正在测试一个具有多个动态行的web应用程序。附近没有可供观察和抓取的东西。我通过抓取一些我可以识别的东西,并切换到我想要操作的文本框或选择器来进入特定字段 看起来像这样 editor = page.find_by_id('grabbable') editor.native.send_keys(:tab, :tab, "Hello World") 我想做的是 tab_amount = tabs(2) editor = page.find_by_id('grabbable') editor.n

我正在测试一个具有多个动态行的web应用程序。附近没有可供观察和抓取的东西。我通过抓取一些我可以识别的东西,并切换到我想要操作的文本框或选择器来进入特定字段

看起来像这样

editor = page.find_by_id('grabbable')
editor.native.send_keys(:tab, :tab, "Hello World")
我想做的是

tab_amount = tabs(2)

editor = page.find_by_id('grabbable')
editor.native.send_keys(tab_amount, "Hello World")


这样的动态选项卡可能吗?

类似的东西怎么样

def tabs(amount)
  tab_object = Array.new(amount, :tab)
end
editor.native.send_key(*选项卡(3),“Hello World”)

这里有一些关于splat的信息


像这样的东西怎么样

def tabs(amount)
  tab_object = Array.new(amount, :tab)
end
editor.native.send_key(*选项卡(3),“Hello World”)

这里有一些关于splat的信息


以下是我最后做的事情

def autotab(amount)
tab = Array.new 
amount.times do
    tab << :tab
end
return tab
end
def自动标签(金额)
tab=Array.new
多少倍

tab以下是我最后做的事情

def autotab(amount)
tab = Array.new 
amount.times do
    tab << :tab
end
return tab
end
def自动标签(金额)
tab=Array.new
多少倍

tab如果字段有两个选项卡,为什么不使用xpath或css选择器来获取所需字段?例如,如果所需的文本字段是一个同级字段和grabbable之后的两个输入字段,则可以使用
page.find(:xpath,'/*[@id=“grabbable”]/following sibling::input[2]”)。set('Hello World')
。如果该字段有两个选项卡,为什么不使用xpath或css选择器来获取所需字段?例如,如果所需的文本字段是一个同级字段和grabbable之后的两个输入字段,则可以使用
page.find(:xpath,'/*[@id=“grabbable”]/following sibling::input[2]”)。set('Hello World')