title: Clicking AJAX links? Watir
body: <p>SOLVED:</p>
  <p>I figured out my problem with this little piece of code:</p>
  <pre><code>b.link(id: 'm_wm_w5_m_lv_ctrl1_m_lnkWatch').fire_event :click
  </code></pre>
  <p>QUESTION:</p>
  <p>I am having trouble clicking AJAX links with Watir.</p>
  <p>Here is what I want to click.</p>
  <p><a href="https://i.imgur.com/Md4Rha3.png" rel="nofollow noreferrer">https://i.imgur.com/Md4Rha3.png</a></p>
  <p>This is what HTML looks like</p>
  <pre><code>&lt;a id=&quot;m_wm_w5_m_lv_ctrl1_m_lnkWatch&quot; href=&quot;javascript:__doPostBack('m_wm$w5$m_lv$ctrl1$m_lnkWatch','')&quot; 
  style=&quot;white-space:nowrap; font-size:11px;&quot;&gt;New Listing (160)&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  <p>So, in Watir, I used the following to click to think</p>
  <pre><code>b.link(id: 'm_wm_w5_m_lv_ctrl1_m_lnkWatch').click
  </code></pre>
  <p>But when I do that, I get this CSS pop up:</p>
  <p><a href="https://i.imgur.com/2DKWAhF.png" rel="nofollow noreferrer">https://i.imgur.com/2DKWAhF.png</a></p>
  <p>The HTML for close button on the pop up is:</p>
  <pre><code>&lt;div id=&quot;NewsDetailDismissNew&quot; class=&quot;btn mtx-btn-confirm enabled&quot; title=&quot;Close&quot;&gt;Close&lt;/div&gt;
  </code></pre>
  <p>But when I use this in Watir</p>
  <pre><code>b.div(id: 'NewsDetailDismissNew').click
  </code></pre>
  <p>Nothing happens.</p>
  <p>I did find some javascript that seems to correspond with the buttons</p>
  <pre><code>&lt;!--&lt;div class=&quot;container&quot; &gt;--&gt;
      &lt;script&gt;
      var cvMarkAsRead=function(  ){ return &quot;Mark as Read&quot;; };
  &lt;/script&gt;
      &lt;script&gt;
      var cvClose=function(  ){ return &quot;Close&quot;; }; //This is closes the CSS pop up as far as I can tell
  &lt;/script&gt;
      &lt;script&gt;
      var cvOK=function(  ){ return &quot;OK&quot;; };
  &lt;/script&gt;
      &lt;script&gt;
      var cvDismiss=function(  ){ return &quot;I've Read This&quot;; };
  &lt;/script&gt;
      &lt;script&gt;
      var cvPreview=function(  ){ return &quot;Print Preview&quot;; };
  &lt;/script&gt;   
  
      &lt;!-- End NewsDetail modal --&gt;
  </code></pre>
  <p>My question to you guys is</p>
  <ol>
  <li><p>How can I click &quot;New Listings&quot; in Watir?</p>
  </li>
  <li><p>How can I click the &quot;Close&quot; button on the pop up?</p>
  </li>
  </ol>
  <p>I see that the link has some javascript, but I am not familiar enough with Watir to use <code>b.execute_script</code> successfully. I read the documentation. I am not understanding it and the examples provided are not similar enough to my problem for me to learn by practicing or copying.</p>
  <p>Thank you in advance.</p>