coolBeans
coolBeans

Reputation: 58

Karate Driver interaction with iframe

Having difficulty with Karate Driver and inputing data into fields that are in an iframe

Have tried using xpath and css selectors to the iframe so I could theoretically switch into and interact with the iframe without any luck. I can find the iframe but I am unsure how to switch context to the iframe so the scenario can continue inside the iframe. For example inputting values into fields in the iframe.

Help Please :)

Update: Can successfully switch into an iframe but now running into an issue with nested iframe.

* switchFrame(0)
* click('.some-checkbox')
* switchFrame(0)

neither iframe has great css selectors. The second switchFrame with an index of 0 is not looking to the nested iframe.

Upvotes: 2

Views: 1870

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58088

I guess you have seen the docs here: https://github.com/intuit/karate/tree/develop/karate-core#switchFrame

I admit this is very tricky. Ideally you have a proper CSS or ID selector to the frame and this is an actual working example from a test I have. Note that the waitFor() may be what you are missing, especially when the <iframe> is some slow loading bloatware.

* waitFor('.some-css-name iframe').switchFrame()
* click('.some-checkbox')
* switchFrame(null)

And unfortunately I have found that this tends to work best on driver type: chrome and chromedriver

Upvotes: 2

Related Questions