微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Google 登录在 WebdriverIO 中被阻止使用 Chromedriver

如何解决Google 登录在 WebdriverIO 中被阻止使用 Chromedriver

我正在尝试为我们的登录方法编写 e2e 测试。这些方法之一是谷歌。但是谷歌通过消息“此浏览器或应用程序可能不安全。”阻止了我的所有尝试。

我已经尝试了一些我在互联网上找到的方法

  1. 滑动 google 帐户 cookie 以测试浏览器。 - 没有结果,我认为与会话有关
  2. 使用 Google 登录其他网站,如本建议中所示Selenium Google Login Block - 无结果
  3. 在我的 wdio.conf.js 中为授权用户指定了 user-data-dir - 没有结果
  4. 在我的 wdio.conf.js 中指定了不同的标志,例如 '--disable-extensions','--test-type','--disable-popup-blocking','--enable-automation','--disable-extensions-file-access-check','--allow-running-insecure-content','--disable-web-security' - 没有结果
  5. 滑动用户代理- 没有结果

您对如何在自动测试中登录 Google 有任何其他想法吗? 谷歌,你为什么讨厌自动测试仪? :'(

我的代码

// wdio.conf.js
capabilities: [{
        browserName: 'chrome',acceptInsecureCerts: true,'selenoid:options':  {
            enableVNC: true,},'goog:chromeOptions': {
        args: [
          '--disable-extensions','--disable-web-security','--profile-directory=Default','--user-data-dir=/Users/{my-user-data}/Library/Application Support/Google/Chrome/Default'
        ]
      }
    }],
// googleAuthTest.ts
describe("Check Google login",() => {
  it("check auth",() => {
    browser.url(url);
    $('.loginWithGoogleButton').click();
    switchWindowToGoogleWindow();

    // I need Google login here:
    $(`[id='identifierId']`).addValue(email);
    $(`[type='button']`).click();
    $(`[name='password']`).addValue(password);
    $(`[type='button']`).click();
    // Google window should closed and i should be loggined on my website.

    switchWindowToMySite();
    // asserts on my site after google auth:
    // some asserts
});

所以,

WebdriverIO 版本:^6.9.1

Chromedriver 版本:89.0.4389.23

Chrome 版本:89.0.4389.90

我有这个结果:Google error

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。