{"id":634,"date":"2012-09-26T17:33:39","date_gmt":"2012-09-26T17:33:39","guid":{"rendered":"http:\/\/psyphi.net\/blog\/?p=634"},"modified":"2012-09-26T17:34:11","modified_gmt":"2012-09-26T17:34:11","slug":"owa-bulk-actions-with-selenium-ide","status":"publish","type":"post","link":"https:\/\/psyphi.net\/blog\/2012\/09\/owa-bulk-actions-with-selenium-ide\/","title":{"rendered":"Another use for Selenium IDE"},"content":{"rendered":"<p>A dear friend of mine recently needed to recover all email from his mailbox. Normally this wouldn&#8217;t be a problem, there are plenty of options in any sane mail application &#8211; export or archive mailbox, select-all messages and &#8220;Send Again&#8221;\/Redirect\/Bounce to another address or at the very worst, select-all and forward. Most of these options are available with desktop mail applications &#8211; Pine, Squirrelmail, IMP, Outlook, Outlook Express, Windows Mail, Mail.app, Thunderbird, Eudora and I&#8217;m sure loads of others.<\/p>\n<p>Unfortunately the only access provided was through Microsoft&#8217;s Outlook Web Access (2007). This, whilst being fairly pretty in Lite (non-Internet Explorer browsers) mode and prettier\/heavier in MSIE, does not have any useful bulk forwarding or export functionality <strong>at all<\/strong>. None. Not desperately handy, to be sure.<\/p>\n<p>Ok, so my first port of call was to connect my Mail.app which supports Exchange OWA access. No dice &#8211; spinning, hanging, no data. Hmm &#8211; odd. Ok, second I tried <a href=\"http:\/\/www.saunalahti.fi\/juhrauti\/index.html\" title=\"fetchExc\" target=\"_blank\">fetchExc<\/a> a Java commandline tool which promised everything I needed but in the end delivered pretty obtuse error messages. After an hour&#8217;s fiddling I gave up with fetchExc and tried falling back to Perl with <a href=\"http:\/\/search.cpan.org\/~wsmith\/Email-Folder-Exchange\/\" title=\"Email::Folder::Exchange on CPAN\" target=\"_blank\">Email::Folder::Exchange<\/a>. This had very similar results to fetchExc but a slightly different set of errors.<\/p>\n<p>After much swearing and a lot more poking, probing and requesting of tips from other friends (thanks Ze) the OWA service was also found to be sitting behind Microsoft&#8217;s <a href=\"http:\/\/www.amazon.co.uk\/gp\/product\/B0043M56VY\/ref=as_li_ss_tl?ie=UTF8&#038;camp=1634&#038;creative=19450&#038;creativeASIN=B0043M56VY&#038;linkCode=as2&#038;tag=psynetwebsol-21\" title=\"Internet Security and Acceleration Server\" target=\"_blank\">Internet Security and Acceleration server<\/a>. This isn&#8217;t a product I&#8217;ve used before but I can only assume it&#8217;s an expensive reverse proxy, the sort of thing I&#8217;d compare to inexpensive Apache + mod_proxy + mod_security on a good day. This ISA service happened to block all remote SOAP (2000\/2003) and WebDAV (2007\/2010) access too. Great! No remote service access whatsoever.<\/p>\n<p>Brute force to the rescue. I could, of course go in and manually forward each and every last mail, but that&#8217;s quite tedious and a huge amount of clicking and pasting in the same email address.\u00c2\u00a0Enter <a href=\"http:\/\/seleniumhq.org\/projects\/ide\/\" title=\"Selenium IDE\" target=\"_blank\">Selenium IDE<\/a>.<\/p>\n<p><a href=\"http:\/\/www.amazon.co.uk\/gp\/product\/1849510261\/ref=as_li_ss_tl?ie=UTF8&#038;camp=1634&#038;creative=19450&#038;creativeASIN=1849510261&#038;linkCode=as2&#038;tag=psynetwebsol-21\" title=\"Selenium\" target=\"_blank\">Selenium<\/a> is a suite of tools for remote controlling browsers, primarily for writing tests for interactive applications. I use it in my day to day work mostly for checking bits of dynamic javascript, DHTML, forms etc. are doing the right things when clicked\/pressed\/dragged and generally interacted with. OWA is just a (<strong>really<\/strong> badly written) webpage to interact with, after all.<\/p>\n<p>I downloaded the excellent <a href=\"https:\/\/github.com\/darrenderidder\/sideflow\" title=\"sideflow on GitHub\" target=\"_blank\">sideflow.js<\/a> plugin which provides loop functionality not usually required for web app testing and after a bit of DOM inspection on the OWA pages I came up with the following plan &#8211;<\/p>\n<ul>\n<li>click the subject link<\/li>\n<li>click the &#8220;forward&#8221; button<\/li>\n<li>enter the recipient address<\/li>\n<li>click the send button<\/li>\n<li>select the checkbox<\/li>\n<li>press the &#8220;delete&#8221; button<\/li>\n<li>repeat 500 times<\/li>\n<\/ul>\n<p>The macro looked something like this:<\/p>\n<pre><code>&lt;table cellpadding=\"1\" cellspacing=\"1\" border=\"1\"&gt;\r\n&lt;thead&gt;\r\n&lt;tr&gt;&lt;td rowspan=\"1\" colspan=\"3\"&gt;owa-selenium-macro&lt;\/td&gt;&lt;\/tr&gt;\r\n&lt;\/thead&gt;&lt;tbody&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;getEval&lt;\/td&gt;\r\n\t&lt;td&gt;index=0&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;while&lt;\/td&gt;\r\n\t&lt;td&gt;index&amp;lt;500&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;storeEval&lt;\/td&gt;\r\n\t&lt;td&gt;index&lt;\/td&gt;\r\n\t&lt;td&gt;value&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;echo&lt;\/td&gt;\r\n\t&lt;td&gt;${value}&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;clickAndWait&lt;\/td&gt;\r\n\t&lt;td&gt;\/\/table[1]\/tbody\/tr[2]\/td[3]\/table\/tbody\/tr[2]\/td\/div\/table\/\/tbody\/tr[3]\/td[6]\/h1\/a&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;clickAndWait&lt;\/td&gt;\r\n\t&lt;td&gt;id=lnkHdrforward&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;type&lt;\/td&gt;\r\n\t&lt;td&gt;id=txtto&lt;\/td&gt;\r\n\t&lt;td&gt;newaddress@gmail.com&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;clickAndWait&lt;\/td&gt;\r\n\t&lt;td&gt;id=lnkHdrsend&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;click&lt;\/td&gt;\r\n\t&lt;td&gt;name=chkmsg&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;clickAndWait&lt;\/td&gt;\r\n\t&lt;td&gt;id=lnkHdrdelete&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;getEval&lt;\/td&gt;\r\n\t&lt;td&gt;index++&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n\t&lt;td&gt;endWhile&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n\t&lt;td&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;\/tbody&gt;&lt;\/table&gt;\r\n<\/code><\/pre>\n<p>So I logged in, opened each folder in turn and replayed the macro in <a href=\"http:\/\/www.amazon.co.uk\/gp\/product\/1849510261\/ref=as_li_ss_tl?ie=UTF8&#038;camp=1634&#038;creative=19450&#038;creativeASIN=1849510261&#038;linkCode=as2&#038;tag=psynetwebsol-21\" title=\"Selenium IDE\" target=\"_blank\">Selenium IDE<\/a> as many times as I needed to. Bingo! Super kludgy but it worked well, was entertaining to watch and ultimately did the job.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A dear friend of mine recently needed to recover all email from his mailbox. Normally this wouldn&#8217;t be a problem, there are plenty of options in any sane mail application &#8211; export or archive mailbox, select-all messages and &#8220;Send Again&#8221;\/Redirect\/Bounce to another address or at the very worst, select-all and forward. Most of these options &hellip; <a href=\"https:\/\/psyphi.net\/blog\/2012\/09\/owa-bulk-actions-with-selenium-ide\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Another use for Selenium IDE&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[11,9],"tags":[822,178,821,820,823,819],"class_list":["post-634","post","type-post","status-publish","format-standard","hentry","category-programming","category-webdev","tag-exchange","tag-macro","tag-outlook","tag-owa","tag-scripting","tag-selenium"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/comments?post=634"}],"version-history":[{"count":7,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/634\/revisions"}],"predecessor-version":[{"id":641,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/634\/revisions\/641"}],"wp:attachment":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/media?parent=634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/categories?post=634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/tags?post=634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}