Empty a Gmail label with FireWatir
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.
By the way, it assumes Gmail is in German. Replace that string with the one that comes up for your language.
1 2 def empty_label(label) 3 # you need a Firefox instance already running with JSSh installed and listening 4 ff = Firefox.new 5 # Goes to Gmail in HTML 6 ff.goto('http://mail.google.com/mail/h/x4odcwnm5f5v/?s=l&l=#{label}') 7 a = [] 8 # doing 'c.set' didn't work for me here so I had to do this hack of getting the value 9 # and then acquiring the element thorugh ff.checkbox(:value,value) 10 ff.checkboxes.each {|c| a << c.value} 11 12 while a.length > 0 do 13 c = [] 14 a.each {|v| c << ff.checkbox(:value,v)} 15 # checks all checkboxes 16 c.each {|e| e.set} 17 # clicks the drop-down entry for deleting 18 ff.select_list(:name,'tact').select('In den Papierkorb verschieben') 19 ff.button(:name,'nvp_tbu_go').click 20 a = [] 21 ff.checkboxes.each {|c| a << c.value} 22 end 23 end