<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: firewatir code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 26 Jul 2008 10:15:03 GMT</pubDate>
    <description>DZone Snippets: firewatir code</description>
    <item>
      <title>Empty a Gmail label with FireWatir</title>
      <link>http://snippets.dzone.com/posts/show/3961</link>
      <description>When you have a huge label with thousands of messages, Gmail can't handle deleting all of them at a time (it says it can, but for me it's never worked). This solves the problem.&lt;br /&gt;&lt;br /&gt;I wrote it more as a practice to get familiar with FireWatir, so it's not very pretty or anything and it's a bit slow. If you have doubts on how to use or suggestions on how to improve it please feel free to contact me.&lt;br /&gt;&lt;br /&gt;By the way, it assumes Gmail is in German. Replace that string with the one that comes up for your language.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def empty_label(label)&lt;br /&gt;  # you need a Firefox instance already running with JSSh installed and listening&lt;br /&gt;  ff = Firefox.new&lt;br /&gt;  # Goes to Gmail in HTML&lt;br /&gt;  ff.goto('http://mail.google.com/mail/h/x4odcwnm5f5v/?s=l&amp;l=#{label}')&lt;br /&gt;  a = []&lt;br /&gt;  # doing 'c.set' didn't work for me here so I had to do this hack of getting the value&lt;br /&gt;  # and then acquiring the element thorugh ff.checkbox(:value,value)&lt;br /&gt;  ff.checkboxes.each {|c| a &lt;&lt; c.value}&lt;br /&gt;&lt;br /&gt;  while a.length &gt; 0 do&lt;br /&gt;    c = []&lt;br /&gt;    a.each {|v| c &lt;&lt; ff.checkbox(:value,v)}&lt;br /&gt;    # checks all checkboxes&lt;br /&gt;    c.each {|e| e.set}&lt;br /&gt;    # clicks the drop-down entry for deleting&lt;br /&gt;    ff.select_list(:name,'tact').select('In den Papierkorb verschieben')&lt;br /&gt;    ff.button(:name,'nvp_tbu_go').click&lt;br /&gt;    a = []&lt;br /&gt;    ff.checkboxes.each {|c| a &lt;&lt; c.value}&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 07 May 2007 21:54:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3961</guid>
      <author>helder (Helder Ribeiro)</author>
    </item>
  </channel>
</rss>
