How often does the node.js mail-listener poll the email box?
By : Delowar Hossain
Date : March 29 2020, 07:55 AM
I hope this helps . mail-listener2 works on the IMAP protocol. It works like your Outlook mail client to receive mails. If your mail server supports the IMAP IDLE protocol, you should get message notifications from the servers as a "push notification" rather than a response to continuous polling.
|
Passing Protractor ElementFinder to deferred.fulfill() results in a promise containing a null value
By : Ahnkili
Date : March 29 2020, 07:55 AM
around this issue I usually use the map, filter, action/assert pattern. It looks something like this: code :
element.all(locator).map(function(elm, index) {
// Get the value you are interested in finding and return the element too.
return {
elm: elm,
text: elm.getText(),
index: index
};
}).then(function(list) {
// Find your text here. Otherwise fail.
for(var i = 0; i<list.length; i++) {
if(list[i].text === name) {
return list[i].elm;
}
}
throw new Error('Solution not found');
}).then(function(elm) {
// Perform an action on the element you found.
elm.click();
});
|
Fetching values from email in protractor test case
By : user3395824
Date : March 29 2020, 07:55 AM
Hope that helps This is something I've solved recently. Hope the solution would also apply for your use-case. Prerequisites: code :
npm install mail-listener2 --save-dev
onPrepare: function () {
var MailListener = require("mail-listener2");
// here goes your email connection configuration
var mailListener = new MailListener({
username: "imap-username",
password: "imap-password",
host: "imap-host",
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;
}),
onCleanUp: function () {
mailListener.stop();
},
function getLastEmail() {
var deferred = protractor.promise.defer();
console.log("Waiting for an email...");
mailListener.on("mail", function(mail){
deferred.fulfill(mail);
});
return deferred.promise;
};
describe("Sample test case", function () {
beforeEach(function () {
browser.get("/#login");
browser.waitForAngular();
});
it("should login with a registration code sent to an email", function () {
element(by.id("username")).sendKeys("MyUserName");
element(by.id("password")).sendKeys("MyPassword");
element(by.id("loginButton")).click();
browser.controlFlow().await(getLastEmail()).then(function (email) {
expect(email.subject).toEqual("New Registration Code");
expect(email.headers.to).toEqual("myemail@email.com");
// extract registration code from the email message
var pattern = /Registration code is: (\w+)/g;
var regCode = pattern.exec(email.text)[1];
console.log(regCode);
});
});
});
|
fulfill deprecated - Updating to protractor 5.0.0
By : Aditya Biswas
Date : March 29 2020, 07:55 AM
around this issue If i understand it right, you can now use the native promises (i hope it's the correct link). Like this way: code :
browser.s2.util.unzip = function(report){
return report.then(function(report){
return new Promise(function(resolve, reject){
try{
// reading archives
var zip = new AdmZip(report);
var zipEntries = zip.getEntries(); // an array of ZipEntry records
zipEntries.forEach(function(zipEntry) {
zipEntry.d = zip.readFile(zipEntry);
});
resolve(zipEntries);
}catch(err){
reject(err);
}
})
});
};
|
Send email using php mail function. Mail is successfully delivered if i remove image from email
By : diakite bakary
Date : March 29 2020, 07:55 AM
help you fix your problem i am also facing the same problem , you can try one small solution. put your message in single quotes and image tag like this  if it stil not work then you can use [PHPMailer][1] [1]: https://github.com/PHPMailer/PHPMailer its very easy to use
|