【问题标题】:Selenium Auth0 can't connect to serverSelenium Auth0 无法连接到服务器
【发布时间】:2016-12-16 01:02:28
【问题描述】:

我对使用protractor conf.js --params.login.username=John --params.login.password=Doe 运行的angular2 进行量角器硒测试。测试将尝试登录我的后端并失败并拒绝访问。

这是conf.js

exports.config = {
  framework: 'jasmine2',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  capabilities: {
    'browserName': 'chrome'
  },
  baseUrl:'http://127.0.0.1:4200',
  specs: ['mytest.spec.js'],
  useAllAngular2AppRoots: true,

  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  }
}

网络驱动程序以webdriver-manager start 启动。该应用程序加载正常,测试填写 Auth0 弹出窗口,如下所示。然后单击提交按钮。但是,这会导致显示下面的错误消息,而不是发生登录。如果我理解正确,Auth0 无法访问身份验证服务器(手动登录时不是问题)。

auth0锁的版本是10.0。

通过browser.pause(),我可以验证是否可以访问其他非本地主机地址,例如 stackoverflow.com。

知道这可能来自哪里以及如何解决它吗?

更新:

在开发者控制台中显示以下消息。

XMLHttpRequest cannot load https://MYDOMAIN.eu.auth0.com/usernamepassword/login. 
Response to preflight request doesn't pass access control check: 
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://127.0.0.1:4200' is therefore not allowed access.

【问题讨论】:

  • 你能检查一下锁是否抛出了错误(还有这个锁是哪个版本的?)
  • 相应地更新了问题并找到了问题。谢谢!

标签: google-chrome selenium angular protractor auth0


【解决方案1】:

问题是,本地 url http://127.0.0.1:4200 没有列在 auth0 仪表板中 Allowed Origins (CORS) 下,只有 http://localhost:4200 我用于手动测试。

已通过将http://127.0.0.1:4200 添加到允许的来源 (CORS) 并将适当的回调 URL 添加到允许的回调 URL 来解决问题。

【讨论】:

    猜你喜欢
    • 2010-11-13
    • 2012-01-24
    • 1970-01-01
    • 1970-01-01
    • 2014-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    相关资源
    最近更新 更多