logo
down
shadow

Protractor Fetching Email with Mail Listener: TypeError: deferred.fulfill is not a function


Protractor Fetching Email with Mail Listener: TypeError: deferred.fulfill is not a function

By : rahul nayar
Date : December 02 2020, 10:46 PM
it fixes the issue The problem seems to be the protractor promise API. Not sure which version of protractor you are using.
In any case, as you are using async/await why not use Promise directly instead of relying on Protractor promises?
code :
export class MailHelper {
  static getLastEmail() {
    const globalAny: any = global;
    return new Promise((resolve, reject) => {
      globalAny.mailListener.on('mail', function (mail, seqno, attributes) {
        resolve(mail);
      });
    });
  }
}


Share : facebook icon twitter icon
How often does the node.js mail-listener poll the email box?

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

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

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

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

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
Related Posts Related Posts :
  • redux how to use state
  • All data in the db is lost when closing a express based node js server
  • How to convert javascript code for Angular
  • XPath select on child nodes
  • Idle event on mouse move - how to stop script permanently on mouse move
  • Why do I get logic is not defined in this code
  • When I enter a number in the input, the first function starts
  • ES6 imports and node_modules hell
  • How to get css selector of clicked-on element?
  • How to auto input MySQL data (input column 1 data to auto input column 2 data with same column) in php?
  • Appending to Datalist Via Javascript
  • Customizing Material-UI Components with Styled-Components
  • Populate elements with class name using Javascript
  • How to execute promises in batches (first resolving 10, then next 10 and so on)
  • Maximo JS automation script: "importPackage" is not defined
  • How to surround selected text inside textarea with <em> on key combination CTRL+i?
  • Your configured registry does not support audit requests ~ On npm audit
  • What's the Angular equivalent of Vue <slot/>?
  • Iconify icon not updating when "data-icon" set with setAttribute()
  • Javascript newbie stuck with XMLHttpRequest return data
  • How to add obj to to state in my example Redux React
  • Loading "grunt-karma.js" tasks...ERROR >> SyntaxError: Unexpected identifier
  • Why do I get log is not defined
  • get the multiple index of the same string
  • How can I iterate over an Array object by using For IN or FOR OF
  • Launch local executable from web browser
  • How to prepare array of json objects to d3 hierarchical tree structure
  • VueJS - event emitted - show HTML before other calculations
  • Export SASS/SCSS variables to Javascript without exporting them to CSS
  • How to attach an event handler only once continuously
  • How to make button open a link in new tab in JavaScript?
  • Find range from the javascript object
  • How can I use my jQuery code as JavaScript?
  • How to show 5 images in a 2 row slider with bxslider
  • How to convert stream into variables in typescript
  • Three.js custom shader error on Chrome GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs
  • My JavaScript doesn't work. How can I solve this problem?
  • Why is this async function is running synchronously?
  • Get updated variable from within react hook before return
  • I want to show all image preview but whenever I upload a new one the old one is gone
  • Would I be able to give access to specific electron APIs safely?
  • Why several clicks fire for each instance of a Class?
  • cant grab value from div using attr()
  • Instantiate subclass without constructing
  • Outputing a created object in javascript to a server side JSON file
  • Transition the numeric labels in a bar chart
  • createBottomTabNavigator: hide just one tab from the tabBar
  • iife vs simple statement behavior with document.title
  • showDialogPopup Refresh Page after Click
  • Child component does not set the initial value passed from the parent: ReactJS
  • Nodejs javascript added to button not responding
  • Trying to define a promise.all
  • Python GEE to extract featurecollection timeseries from Landsat imageries
  • How to write negative binary number?
  • Unable to set property of individual object
  • Why Named Function Expression itself cannot assign Name to another Value?
  • How to reset scroll position on single page pagination
  • How to scroll to bottom of page, when a new message is sent - Socket.io
  • How to reconstruct audio blob from a base64 encoded String?
  • How to calculate numbers within an array of objects
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org