对量角器6.0,角度7和甜蜜警报2.0中的甜蜜警报执行断言

时间:2019-03-28 12:17:54

标签: protractor angular7 sweetalert2

在我注册用户后,会发出甜蜜的警报,提示我是否成功。我无法使用量角器声明相同的内容。

我已尝试在相关的旧帖子中找到答案,搜索文档,但没有找到答案。

我的规格是:

    it('should go to login page, navigate to register page and register new user', async () => {
        const loginButton = element(by.id('loginButton'));
        await loginButton.click();
        const registerUserButton = element(by.id('registerUserButton'));
        await registerUserButton.click();
        // register page
        const name = element(by.id('usersName'));
        const password = element(by.id('password'));
        const confirmPassword = element(by.id('confirmPassword'));
        const email = element(by.id('email'));
        const number = element(by.id('number'));
        const gender = element(by.id('gender'));
        const submitButton = element(by.id('submitButton'));
        // giving values to form data input fields
        await name.sendKeys('testUser');
        await password.sendKeys('testUser123');
        await confirmPassword.sendKeys('testUser123');
        await email.sendKeys(new Date().toDateString().split(' ').join('') + new Date().getTime() + '@gmail.com');
        await number.sendKeys('9712312323');
        await gender.sendKeys('male');
        await submitButton.click();

        // checking alert
        const alertDialog = await browser.driver.switchTo().alert();
        expect(await alertDialog.getText()).toEqual('Success!! You\'ve successfully registered');
    });

sweetalert代码是:

    Swal.fire({
        type: 'success',
        title: 'Success!! You\'ve successfully registered',
        text: 'You\'re provided with 50 free loyalty points. Welcome to Star Hotel',
        timer: 50000,
        confirmButtonText: 'Cool'
      });

错误:  -失败:没有此类警报     (会议信息:chrome = 73.0.3683.86)     (驱动程序信息:chromedriver = 2.46.628402(536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform = Windows NT 10.0.17134 x86_64)

但是自动化进行得很好,并且用户已注册,并且会弹出警报并显示给定的成功消息。 我没有找到有关使用定位器发出甜蜜警报的任何材料,但我假设它的核心仍然是JavaScript警报。

0 个答案:

没有答案