Транспортир - получить текст из тоста или уведомления - PullRequest
0 голосов
/ 26 марта 2020

Мы пытаемся выполнить getText () и использовать его в ожидаемом состоянии из тоста или уведомления, которое отображается только в течение нескольких секунд.

Spe c file

const projectsPage = require('../page-objects/projects-page');
const docsHomePage = require('../page-objects/docs-home-page');
describe('Non Angular CLM Page', () => {
 it('Apply permission to a folder', async () => {
        try {
            await docsHomePage.clickProject();
            await projectsPage.projectCreateNewFolderAndSelect("AutoProject");       
    } catch(err) {
        console.log(err);
    }
    });
})

Page-Object

const EC = browser.ExpectedConditions;
var newFolderName = null;
class ProjetcsPage {
    async projectCreateNewFolderAndSelect(projectName) {
        await this.selectProject(projectName);
        await this.clickProjectsPlusIcon();
        await this.clickCreateNewFolder();
            var d = new Date();
                var n = d.getTime();	  
                var folderName1="Drawings"+n;
                newFolderName=folderName1;
                var folderName= folderName1+'\n';
                await this.enterFolderName(folderName);
                const notificationMessage = this.getNotificationMessageText();
          expect(notificationMessage).toEqual(newFolderName+' has been updated');
          await this.openFolder(newFolderName);
          return newFolderName
     }
     
   async getNotificationMessageText() {
      browser.wait(EC.visibilityOf(element(by.css(".notification-bottom-bar.show"))), 30000);
   const toastmsg=  element(by.css(".notification-bottom-bar.show")).getText().then(function(msgtext) {
            console.log('--------------------------------'+msgtext);
            return msgtext; 
            });
        
     }

Ниже приведен html источник тостового сообщения. enter image description here

Получение следующего сообщения об ошибке: enter image description here

...