Protractor 如何通过量角器代码单击电子邮件中的链接
我使用的是量角器,我需要测试忘记密码的情况。因此,当我单击忘记密码时,它将要求输入emailid,并在该电子邮件中获得一个链接。我需要单击该链接。为此,我已尝试使用mail-listener4,并将其添加到配置文件中,如下所示Protractor 如何通过量角器代码单击电子邮件中的链接,protractor,cucumberjs,Protractor,Cucumberjs,我使用的是量角器,我需要测试忘记密码的情况。因此,当我单击忘记密码时,它将要求输入emailid,并在该电子邮件中获得一个链接。我需要单击该链接。为此,我已尝试使用mail-listener4,并将其添加到配置文件中,如下所示 onPrepare: function() { browser.ignoreSynchronization = true; browser.manage().window().maximize(); var MailListener = require("mai
onPrepare: function() {
browser.ignoreSynchronization = true;
browser.manage().window().maximize();
var MailListener = require("mail-listener4");
// here goes your email connection configuration
var mailListener = new MailListener({
username: "rosemol.davis@cloudium.io",
password: "Csoft123!",
host: "cmail.cloudium.io",
port: 993, // imap port
tls: true,
tlsOptions: { rejectUnauthorized: false },
mailbox: "INBOX", // mailbox to monitor
searchFilter: ["UNSEEN", "FLAGGED"], // the search filter being used after an IDLE notification has been retrieved
markSeen: true, // all fetched email willbe marked as seen and not fetched next time
fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
mailParserOptions: {streamAttachments: true}, // options to be passed to mailParser lib.
attachments: true, // download attachments as they are encountered to the project directory
attachmentOptions: { directory: "attachments/" } // specify a download directory for attachments
});
mailListener.start();
mailListener.on("server:connected", function(){
console.log("Mail listener initialized");
});
global.mailListener= mailListener;
}
在basedefention.js文件中添加,如下所示
When(/^I get email content$/, function () {
function getLastEmail() {
var deferred = protractor.promise.defer();
console.log("Waiting for an email...");
mailListener.on("mail", function(mail){
console.log("emailParsed", mail);
console.log("mailon");
deferred.fulfill(mail);
});
return deferred.promise;
};
browser.wait(getLastEmail()).then(function (email) {
console.log("email","%%%%%%%%%%%%%%%%%");
console.log(email);
console.log(email.text,"###########################@@@@@@");
});
});
但是当我执行这段代码时,我只能在命令提示符中看到文本“邮件侦听器已初始化”和“等待电子邮件…”。我认为mailstener.on(“mail”,函数(mail){}部件未执行,本节中给出的console.log不起作用。我尝试了mail-listener4和mail-listener2,两者都给出了相同的结果。我哪里出了问题?如何解决此问题,或者如何访问电子邮件中的链接?提前感谢。我正在使用mailsac.com解决此问题