SOLVED:
Resolved my issue by implementing this code snippet:
b.link(id: 'm_wm_w5_m_lv_ctrl1_m_lnkWatch').fire_event :click
QUESTION:
Encountering difficulty clicking AJAX links using Watir.
The specific element I am trying to click is located at:
https://i.sstatic.net/Du1js.png
Provided HTML structure for reference:
<a id="m_wm_w5_m_lv_ctrl1_m_lnkWatch" href="javascript:__doPostBack('m_wm$w5$m_lv$ctrl1$m_lnkWatch','')"
style="white-space:nowrap; font-size:11px;">New Listing (160)</a></td>
To interact with the element in Watir, I utilized the following command:
b.link(id: 'm_wm_w5_m_lv_ctrl1_m_lnkWatch').click
However, upon execution, a CSS popup appeared:
https://i.sstatic.net/ApDFj.png
Closed button within the CSS popup can be identified in the following manner:
<div id="NewsDetailDismissNew" class="btn mtx-btn-confirm enabled" title="Close">Close</div>
Despite attempting to interact with it through Watir:
b.div(id: 'NewsDetailDismissNew').click
No action was observed.
Further investigation led me to discover relevant javascript functions associated with the buttons:
<!--<div class="container" >-->
<script>
var cvMarkAsRead=function( ){ return "Mark as Read"; };
</script>
<script>
var cvClose=function( ){ return "Close"; }; //This is closes the CSS pop up as far as I can tell
</script>
<script>
var cvOK=function( ){ return "OK"; };
</script>
<script>
var cvDismiss=function( ){ return "I've Read This"; };
</script>
<script>
var cvPreview=function( ){ return "Print Preview"; };
</script>
<!-- End NewsDetail modal -->
Seeking input on the following inquiries:
How can I successfully trigger the "New Listings" link with Watir?
Is there a method to effectively select the "Close" button on the displayed popup?
Although the link contains javascript, I am uncertain about leveraging b.execute_script
within Watir. Despite referencing documentation and examples, I have encountered difficulties grasping the concept sufficiently to apply it accurately to my scenario.
Your assistance is greatly appreciated.