Hi @4280-kazurayam @Andrej Podhajský @Russ Thomas and others,
We are using Katalon for testing web application with angular components and from UI level there is no issue (shadow DOM works fine) but in some instances it would help us if we could make direct calls to angular objects or services (to avoid going trough UI… and here I don’t mean REST APIs but calling directly angular services).
For example, within Chrome console I can make a call for getAllAngularRootElements(); or ng.probe($$(‘component-name’)).componentInstance.appTitle.length; and those return successfully and I just want to be able to do the same using Katalon Studio.
it returns error like this
_ (Session info: chrome=70.0.3538.102)_
_ (Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)_
Is there a way around this? Any suggestions?
I have attached couple of screenshots to maybe explain better what I am asking for.
We got it to work
Very simple solution.
Instead of passing $$(‘component-name’) to
**we are passing query selector (and this eliminated $$ error)
**this is how the final call looks…
In case you are calling a method that does not return anything you just need to remove **return **from the JS.
Just to mention… appTitle.length I used just as an example (not something we need in our tests) but the concepts applies to any angular object property or method…
+1 Yes, excellent job, Rasko!
I’m intrigued though, why $$ isn’t working for you. (Warning - I’m not experienced using angular – is $$ provided by it?)
Pretending now that you were using something like jQuery… if jQuery’s $() calls fail. it’s usually because the context has changed, perhaps because there’s an iframe involved. But then, it’s usually the case that the console fails… I find this very strange…
I’m basically saying, I’d really want to know why a console call works, but the same code fails in a groovy->js call. That’s not how Katalon/groovy is meant to behave. And if there are issues with the groovy->js infrastructure, I’d want (need!) them fixed, asap.