[英]Watir-webdriver, cannot interact with a div popup
I cannot figure out a way to interact with the highlighted HTML: 我不知道一种与突出显示的HTML进行交互的方法:
When I click on a link, an interactive modal appears, which has a table to allow user to buy parts. 当我单击链接时,将出现一个交互式模式,该模式具有一个表格,允许用户购买零件。 Also, the modal has links that open up new sections within the modal.
此外,该模态具有在模态内打开新部分的链接。
I have tried to write step definitions but cannot get test to pass. 我试图编写步骤定义,但无法通过测试。 See below for my (latest attempt) code:
请参阅以下我的(最新尝试)代码:
When /^I click on the Buy icon of loan part selected$/ do
@browser.div(:id, 'modal_loan_parts_table').link(:text, 'Buy').click
end
The error I keep getting is element not located
. 我一直收到的错误是
element not located
。 Can someone please direct me to enlightenment? 有人可以指导我进行启示吗?
Here is the error that occured: 这是发生的错误:
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'
Many Thanks Guys! 非常感谢你们!
I found the solution without using xpath. 我找到了不使用xpath的解决方案。 Here is my code and it works:
这是我的代码,它可以正常工作:
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
Many thanks to everyone. 非常感谢大家。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.