使用远程 Web 测试框架(BrowserStack 和 LamdaTest)时,Chrome 上的表单输入条目失败 [英] Form input entry fails on chrome when using Remote Web Testing framworks (BrowserStack and LamdaTest)

查看:63
本文介绍了使用远程 Web 测试框架(BrowserStack 和 LamdaTest)时,Chrome 上的表单输入条目失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的测试套件在本地以及使用 Chrome 的 gitlab 管道中都可以正常工作.

My test suite works fine locally as well as in gitlab pipeline using Chrome.

但是,在远程测试框架上使用 Chrome(仅)运行它们时,它们会在登录页面上失败.
我测试了 BrowserStack 和 LamdaTest,当我尝试在表单输入字段中输入文本时,它们都失败了.

However, they fail right on the login page when running them with Chrome (only) on Remote Testing frameworks.
I tested BrowserStack and LamdaTest and they both fail when I attempt to enter text in a form input field.

错误信息是:

{"sessionId":"d6c0edadf898c18d38e9dda073a868fa","status":61,"value":{"message":"invalid argument: 'value' must be a list\n (Session info: chrome=80.0.3987.87)\n (Driver info: chromedriver=80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}),platform=Windows NT 10.0.14393 x86_64)"}}

相同的测试适用于 Safari 和 Firefox,只有 Chrome 失败.我花了一些时间与 LambdaTest 的人一起调查,似乎在使用常规"时一切正常.selenium 选择器和动作,只有在使用空手道时才会失败.
有没有人遇到过同样的问题?

The same tests work on Safari and Firefox, only Chrome fails. I spent some time investigating with the guys at LambdaTest and it seems it all works fine when using "regular" selenium selectors and actions, and only fails with Karate.
Has anyone experienced the same issue?

添加由 Prateek Singh

Request POST http://hub.lambdatest.com /wd/hub/session/719c9157598420fb3e272f53be31ab51/elements  
   { using: 'css selector', value: 'input[type=text]' }

Response 200 POST http://hub.lambdatest.com/wd/hub/session/719c9157598420fb3e272f53be31ab51/elements (461ms)
   {
     sessionId: '719c9157598420fb3e272f53be31ab51',
     status: 0,
     value: [ { ELEMENT: '0.37079523975334916-2' } ]
   }
   
Request POST http://hub.lambdatest.com /wd/hub/session/719c9157598420fb3e272f53be31ab51/element/0.37079523975334916-2/value  
   {
     value: [
       'L', 'a', 'm',  'b',
       'd', 'a', 'T',  'e',
       's', 't', '\n'
     ]
   }

Response 200 POST http://hub.lambdatest.com/wd/hub/session/719c9157598420fb3e272f53be31ab51/element/0.37079523975334916-2/value (1366ms)
   {
     sessionId: '719c9157598420fb3e272f53be31ab51',
     status: 0,
     value: null
   }

推荐答案

您的远程提供商似乎不符合 W3C 规范.例如,对 /element 调用的响应应该是这样的,我知道你已经使用了 elements 但你可以看出响应shape"适用于旧的不合规的 chrome 驱动程序:

Your remote providers don't seem to be conforming to the W3C spec for chromedriver. For example the response to the /element call should be something like this, I know you have used elements but you can tell that the response "shape" is for the old non-compliant chrome-driver:

3 > POST http://localhost:9515/session/87ff90ad57ad432540b413740a66f7c1/element
3 > Content-Type: application/json; charset=UTF-8
3 > Content-Length: 43
3 > Host: localhost:9515
3 > Connection: Keep-Alive
3 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_231)
3 > Accept-Encoding: gzip,deflate
{"using":"css selector","value":"#inputId"}

20:59:25.475 [main] DEBUG com.intuit.karate - response time in milliseconds: 9
3 < 200
3 < Content-Length: 88
3 < Content-Type: application/json; charset=utf-8
3 < cache-control: no-cache
{"value":{"element-6066-11e4-a52e-4f735466cecf":"d7bdd4a1-17bc-4ee0-817b-cf7052641d25"}}

以及对element/value 肯定是错误的,这是一个符合规范的请求的例子,其中参数 text 应该在有效负载中(不是 value 下的数组):

And the request to element/value is certainly wrong, this is an example of a spec-compliant request, where the parameter text is expected in the payload (not an array under value):

4 > POST http://localhost:9515/session/87ff90ad57ad432540b413740a66f7c1/element/d7bdd4a1-17bc-4ee0-817b-cf7052641d25/value
4 > Content-Type: application/json; charset=UTF-8
4 > Content-Length: 22
4 > Host: localhost:9515
4 > Connection: Keep-Alive
4 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_231)
4 > Accept-Encoding: gzip,deflate
{"text":"hello world"}

20:59:25.560 [main] DEBUG com.intuit.karate - response time in milliseconds: 83
4 < 200
4 < Content-Length: 14
4 < Content-Type: application/json; charset=utf-8
4 < cache-control: no-cache
{"value":null}

这一定是其他浏览器可以工作的原因——也许是因为您的 LambdaTest 设置使用的是旧版本的 chrome 驱动程序.空手道将不支持旧版本,但如果适用,我们很乐意修复与 W3C 标准的任何差距.

This must be reason why other browsers are working - perhaps because your LambdaTest setup is using an old version of the chrome-driver. Karate will not support the old version, but we will be happy to fix any gaps vs the W3C standard if applicable.

作为参考,这些是我使用的 chrome-driver 返回的功能:

For reference, these are the capabilities returned by the chrome-driver I used:

{
   "value":{
      "capabilities":{
         "networkConnectionEnabled":false,
         **"chrome":{
            "chromedriverVersion":"87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs\/branch-heads\/4280@{#1761})",
            "userDataDir":"\/var\/folders\/py\/d2vyrn2n3bz7yzp7rppntw7cvsmbgv\/T\/.com.google.Chrome.JJHuOI"
         },
         "acceptInsecureCerts":false,
         "browserVersion":"87.0.4280.141",
         "browserName":"chrome",
         "platformName":"mac os x",
         "setWindowRect":true,
         "webauthn:virtualAuthenticators":true
      },
      "sessionId":"87ff90ad57ad432540b413740a66f7c1"
   }
}

这篇关于使用远程 Web 测试框架(BrowserStack 和 LamdaTest)时,Chrome 上的表单输入条目失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆