-1

I'm trying to call in-browser ExtJS query from Karate scenario with the following code:

* def someFunc = function(q) { return Ext.ComponentQuery.query(q)[0].itemId }
* print someFunc('#myItem')

But I always get "Ext" not defined in <eval>

What I am doing wrong?

jtiai
  • 611
  • 5
  • 11
  • that's not how Karate works. read the docs: https://github.com/intuit/karate/tree/master/karate-core – Peter Thomas Apr 29 '20 at 13:02
  • Unfortunately I need to do that since ExtJS doesn't provide any normal IDs to get some elements from DOM than querying it's own internal structure. Elements do have ID attribute set but they are auto generated with random ids so they are not reliable. – jtiai Apr 30 '20 at 05:20

1 Answers1

1

Karate uses two different JavaScript running methods - embedded and in-browser.

Normally everything is run using embedded version and thus doesn't have any access to browser objects - this isn't very clearly stated in the docs.

One solution:

 * def someFunc = function(q) { return script("Ext.ComponentQuery.query('" + q + "')[0].itemId") }
jtiai
  • 611
  • 5
  • 11
  • your question was incomplete, which is why I downvoted it, now it is clear what you are trying to do - so if you edit the question mentioning that you are trying to call an "in-browser" JS function, this is a piece of cake for Karate. here is a good reference, and look at the links to other answers: https://stackoverflow.com/a/60800181/143475 – Peter Thomas Apr 30 '20 at 05:24