0

当尝试通过 Watir 中的 x-path 来单击 jquery [+} 树时,我收到以下错误错误的参数数量(3 for 1)(ArgumentError)

When /^Go to e-Care and search for the policy created$/ do

link = element_by_xpath(String("//{0}[contains(normalize-space(text()),{1})]", "a",`enter code here` "Actions"))
link_parent = link.element_by_xpath((".."))
plus_div = link_parent.element_by_class(("expandable-hitarea"))
plus_div.click

end
4

2 回答 2

0

当需要单个参数时,您将多个参数传递给 String.new:

element_by_xpath(String("//{0}[contains(normalize-space(text()),{1})]", "a",`enter code here` "Actions"))

例子:

String.new("foo")
=> "foo"
String.new("foo", "bar")
=>  wrong number of arguments (2 for 0..1) (ArgumentError)
于 2013-01-12T16:36:28.620 回答
0

在 Watir 中,您的步骤将写为:

When /^Go to e-Care and search for the policy created$/ do
  link = @browser.link(:text => "Actions")
  link_parent = link.parent
  plus_div = link_parent.element(:class => "expandable-hitarea")
  plus_div.click
end

这假定您的 watir 浏览器对象存储在@browser实例变量中。

于 2013-01-15T15:25:02.170 回答