0

我想不出一种与突出显示的 HTML 交互的方法:

在 js 模态中购买商品

当我点击一个链接时,会出现一个交互式模式,其中有一个允许用户购买零件的表格。此外,模态具有在模态中打开新部分的链接。

我试图编写步骤定义,但无法通过测试。请参阅下面的我的(最新尝试)代码:

When /^I click on the Buy icon of loan part selected$/ do
  @browser.div(:id, 'modal_loan_parts_table').link(:text, 'Buy').click
end

我不断收到的错误是element not located. 有人可以指导我启蒙吗?

这是发生的错误:

  unable to locate element, using {:id=>"modal_loan_parts_table", :tag_name=>"div"} (Watir::Exception::UnknownObjectException)
  ./step_definitions/secondarymkt_buying_lp.rb:62:in `/^I click on the Buy icon of loan part selected$/'
  secondarymkt_buying_lp.feature:27:in `When I cllick on the Buy icon of loan part selected'

非常感谢伙计们!

4

1 回答 1

0

我在不使用 xpath 的情况下找到了解决方案。这是我的代码,它有效:

When /^I click on the Buy icon of loan part selected$/ do
  @browser.div(:id, 'details-ajax-modal').wait_until_present
  @browser.div(:id, 'details-ajax-modal').exists?
  @browser.link(:class, 'modal-buy').wait_until_present
  @browser.link(:class, 'modal-buy').click
end

非常感谢大家。

于 2013-01-25T11:25:38.847 回答