* @param orderNumber the order number for the expected email message.
* @return the html source code for the email message.
*/
public String getBuyerMessageMail(final String email, final String password,
final String orderNumber) {
DefaultSelenium gmailSeleniumRC = null;
try {
String gmailUrl = "http://gmail.google.com";
gmailSeleniumRC = createSeleniumRc(gmailUrl);
gmailSeleniumRC.start();
gmailSeleniumRC.open(gmailUrl);
gmailSeleniumRC.waitForPageToLoad("30000");
//login
gmailSeleniumRC.type("Email", email);
gmailSeleniumRC.type("Passwd", password);
gmailSeleniumRC.click("name=signIn");
gmailSeleniumRC.waitForPageToLoad("30000");
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
log.warn("Interrupted sleep", e);
}
gmailSeleniumRC.selectFrame("main");
gmailSeleniumRC.selectFrame("v1");
gmailSeleniumRC.waitForCondition(
"selenium.browserbot.getCurrentWindow()"
+ ".document.getElementsByName('q')[0].value='" + orderNumber + "'",
"1000");
gmailSeleniumRC.submit("id=s");
//open result if any
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
log.warn("Interrupted sleep", e);
}
gmailSeleniumRC.keyPress("xpath=//body", "o");
String result = gmailSeleniumRC.getHtmlSource();
return result;
} finally {
if (gmailSeleniumRC != null) {
gmailSeleniumRC.stop();
}
}
}