1

I'm using Karate v0.9.6.RC1. The code is something like this: * switchFrame(1) And input('input[name='cardnumber']','xxxxxxx')

This works fine in Chrome or Edge browser but fails in Firefox or Safari. I tried using different methods like Click, Input, Retry etc after switching to frame but Firefox/Safari doesn't even recognise the object. Also tried different locators. It fails with the below error:

21:14:08.687 request:
101 > POST http://localhost:4444/session/803f524c-3eda-8d46-b1f3-b7ee4c9bc83a/element
101 > Accept-Encoding: gzip,deflate
101 > Connection: Keep-Alive
101 > Content-Length: 59
101 > Content-Type: application/json; charset=UTF-8
101 > Host: localhost:4444
101 > User-Agent: Apache-HttpClient/4.5.12 (Java/1.8.0_242)
{"using":"css selector","value":"input[name='cardnumber']"}

21:14:08.692 response time in milliseconds: 4.54
101 < 404
101 < cache-control: no-cache
101 < content-length: 302
101 < content-type: application/json; charset=utf-8
101 < date: Sun, 12 Apr 2020 13:14:08 GMT
{"value":{"error":"no such element","message":"Unable to locate element: 

input[name='cardnumber']","stacktrace":"WebDriverError@chrome://marionette/content/error.js:175:5\nNoSuchElementError@chrome://marionette/content/error.js:387:5\nelement.find/

21:14:08.692 http response code: 404, response: {"value":{"stacktrace":"WebDriverError@chrome://marionette/content/error.js:175:5\nNoSuchElementError@chrome://marionette/content/error.js:387:5\nelement.find/ POST http://localhost:4444/session/803f524c-3eda-8d46-b1f3-b7ee4c9bc83a/element 102 > Accept-Encoding: gzip,deflate 102 > Connection: Keep-Alive 102 > Content-Length: 59 102 > Content-Type: application/json; charset=UTF-8 102 > Host: localhost:4444 102 > User-Agent: Apache-HttpClient/4.5.12 (Java/1.8.0_242) {"using":"css selector","value":"input[name='cardnumber']"}

I'm not sure if I'm missing something here. Any inputs would be appreciated.

Vijay
  • 47
  • 3

1 Answers1

1

Yes I don't think the FF and Safari browsers implement frame-switching correctly. I could be wrong, but having tried a bit and given up - you are welcome to dig into the code / spec and fix this. PR-s welcome !

I also suggest exploring if you can achieve this via JS, here are some ideas: https://stackoverflow.com/a/60800181/143475

Note that Karate is very easy to contribute to, we have a detailed guide: https://github.com/intuit/karate/wiki/Developer-Guide

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248