静静子
静静子

Reputation: 29

Is there any way to get the request URL in karate UI test? not the current url in browser, because the site can’t be reached

when I do UI test in karate, I want to get a request url from web, the page will not load, every time the request url will have a unique code in it, the code is what I need in later test.

I cannot use * def actualUrl = waitForUrl('*') to get it because it will give "chrome-error://chromewebdata/", and * def currentUrl = driver.execute_Script("return window.location.href;") is not able to use, karate says execute_Script is not a defined method. Please help, thank you enter image description here

Upvotes: 1

Views: 45

Answers (2)

静静子
静静子

Reputation: 29

I have found a method to solve my question:

def frameTree = driver.send({ method: 'Page.getFrameTree' })

I can use this sentence to get the unreachableUrl

Upvotes: 0

Peter Thomas
Peter Thomas

Reputation: 58088

Sounds like the page wasn't even loaded.

See if this answer helps: https://stackoverflow.com/a/66813293/143475

Also refer: https://stackoverflow.com/a/61678536/143475

Upvotes: 0

Related Questions