WebDriverIO - 处理提示登录消息

问题描述 投票:0回答:1

我已经在这一段时间了,但无法通过文件找到任何解决方案。

基本上我在需要密码凭据的QA环境中进行测试。

虽然我可以手动输入用户名/密码,但理想情况下我希望在测试中自动输入。

这可以通过WebdriverIO实现吗?

enter image description here

javascript selenium-webdriver webdriver selenium-chromedriver webdriver-io
1个回答
0
投票

如上所述,只需在URL中添加凭据(使用您自己的userNamepassWord

const credentials = `https://userName:passWord@`
const URLEnv = 'www.google.com'
const url = credentials + URLEnv

....

describe('Google page', () => {
    it('should have the right title', () => {
        browser.url(url);
        const title = browser.getTitle();
        const correctResult = 'Google'
        expect(title).toEqual(correctResult);
    });
});
© www.soinside.com 2019 - 2024. All rights reserved.