For my mobile webapp, I am attempting to create a test using cucumber+watir-webdriver. However, I am encountering difficulty when trying to select a specific link on a splash message.
The link I need to choose is
<a class="btn" href="#">Close button</a>
, which is dynamically generated on the page through javascript.
I have attempted to use various selectors:
browser.link :text => 'Close button'
browser.link(:class,"btn")
browser.div(:id,"vf_dialog_desc").link(:class,"btn") # with surrounding div
browser.div(:xpath,"//div[@id='vf_dialog_desc']/descendant::a[text()='Close button']")
Unfortunately, all of these attempts have failed, resulting in an error message similar to:
Error: {"message":"Unable to locate an element with the xpath expression (...snip xpath expression...) because of the following error:\nTypeError: Object #<an HTMLDocument> has no method 'evaluate'"}
Coincidentally,
browser.html.include? 'Close button'
returns true, indicating that watir can indeed access the element.
It is important to note that this particular page is not contained within a frame.
The structure of the page is as follows:
<html>
<head>...</head>
<body>
<div id="home">
<div id="vf_dialog_holder" class=" show">
(...)
<div id="vf_dialog_wrap">
<h4 id="vf_dialog_head" style="display: block;" class=" vf_dialog_info_icon">Welcome to xpto</h4>
<div id="vf_dialog_desc">
<img src="884857.jpg">
<p>Blurb.</p>
<a class="btn" href="#">Close button</a>
</div>
<div class="clr">
</div>
</div>
I am currently using watir-webdriver (0.6.4) on ruby-2.0.0-p247.