WebdriverIO Saucelabs bug,browser.getUrl 指的是开始的 url,但不是当前的 url

发布于 2025-01-16 22:47:29 字数 478 浏览 1 评论 0原文

当我在远程(CI+saucelabs 或本地计算机 + saucelabs 远程)上的测试不相似时,我遇到了问题。

我有一个网站(例如 example.com)

我的方案包括以下步骤:

  1. 打开 example.com
  2. 单击“登录”按钮
  3. 填写表单并单击“登录”
  4. 表单 重定向到另一个网站(例如 example2.com)
  5. 继续使用 第 5 步中的另一个站点

- browser.getUrl() 应该引用 example2.com(在没有 Saucelabs 的本地执行中,这是正确的),但在 Saucelabs 上我得到 example.com。

环境:

nodejs:16.13.1

npm:8.1.2

库:

@wdio/cli:6.10.11

@wdio/sauce-service:6.3.6

I'm faced with issue when my tests on remote (CI+saucelabs or local machine + saucelabs remote) are not the similar.

I have a site (e.g. example.com)

My scenario consists on next steps:

  1. open example.com
  2. click to "login" button
  3. fill form and click to "sign in"
  4. forms redirect to another site (e.g. example2.com)
  5. proceed working with another site

inside the step 5 - browser.getUrl() should refers to example2.com (on local execution without saucelabs it's true), but on saucelabs I get example.com.

env:

nodejs: 16.13.1

npm: 8.1.2

libs:

@wdio/cli: 6.10.11

@wdio/sauce-service: 6.3.6

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

能怎样 2025-01-23 22:47:29

如果没有看到更多代码,很难判断,但我怀疑问题要么与时间相关,要么与 Selenium 进行了一些奇怪的缓存有关。

(在本例中,Sauce Labs 充当代理;除了向 Selenium 发送命令并将响应转发回测试运行器之外,它什么也不做。)

Sauce Labs 浏览器和您的 SUT 之间的网络距离将不同于本地之间的网络距离 。浏览器和您的 SUT...尤其是当 SUT 位于您的公司网络内部时。这让我怀疑 Sauce Labs 浏览器可能需要等待更长时间才能完全加载 SUT,并且浏览器本身告诉 Selenium 它仍然位于错误的页面上。

如果您添加一个 browser.waitUntil(browser.getUrl() === "desired_url", timeout),超时为“30000”,您的测试是否开始工作?如果是这样,则说明浏览器加载时间存在问题,您可以看看可以采取哪些措施来缩短加载时间,只需保持等待即可。

不过,我会在诊断后将超时值降低到更合理的值。

Without seeing more code it's hard to tell, but I suspect the problem is either timing related, or Selenium doing some weird caching.

(Sauce Labs acts as a proxy in this instance; It does nothing besides send commands to Selenium and relay responses back to your test runner.)

The network distance between a Sauce Labs browser and your SUT is going to be different than that between your local browsers and your SUT... especially if the SUT is located inside your corporate network. That makes me suspect there Sauce Labs browser may have to wait longer for your SUT to completely load, and the browser itself is telling Selenium it's on the wrong page still.

If you add a browser.waitUntil(browser.getUrl() === "desired_url", timeout), with a timeout of "30000", does your test start working? If so, it is a problem with the browser load time and you can either see what you can do to improve load time or just leave the wait in place.

I'd lower the timeout value after diagnosis though, to something more sensible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文