Deleting Trac Spam with Selenium

The CFEclipse Trac wiki has been polluted with spam for quite some time now.  We’ve finally got the spam under control but faced a big task of going in and cleaning up all the spam related pages.  I started doing it manually and quickly realized this was something I could automate with a bit of creative thinking.

I cranked up Selenium IDE and recorded myself manually deleting a page or two.  Looking at the resulting HTML test code I started hacking.

I had a list of all the spam pages via the Index page from Trac.  I cleaned that up into a comma delimited list.  Than I hacked up a short ColdFusion script to loop through the list and write out some HTML following the format of the Selenium test:

<tr> <!-- click spam link -->
<td>clickAndWait</td>
<td>link=401_buy_oxytrol
</td>
<td></td>
</tr>
<tr> <!-- click delete page button on spam page -->
<td>clickAndWait</td>
<td>//input[@value='Delete page']</td>
<td></td>
</tr>
<tr> <!-- click confirmation delete button -->
<td>clickAndWait</td>
<td>//input[@value='Delete page']</td>
<td></td>
</tr>

In hindsight I could have probably hacked my CF loop directly into my Selenium script and saved (and run) it as a .cfm.

I had well over 100 spam links to delete. I fired off the revised Selenium script in Selenium IDE and set on a medium speed (I didn’t want anything to timeout) and it chugged through these in a minute or two.

Done!   Probably not an intended use for Selenium but it worked and saved me a huge amount of manual labor.

Recent Related Posts

One thought on “Deleting Trac Spam with Selenium

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>