我们的基础 Url 重定向到另一个 URL 我们可以在日志中看到它有一个我们需要存储和传递子后续请求的变量

Our base Url redirects to another URL which we can see in logs and this has a variable we need to store and pass in sub subsequent request

使用空手道-UI

   Given driver 'http://localhost:8080/auth/realms/auth?scope=openid&state=eferov08J37HlzbycjxHGs4.xzyoGFvM3QQ.test&response_type=code&client_id=hetg&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauth%2Frealms%2Fendpoint'
    * fullscreen()
    And delay(2000)
    And input('#username', 'username')
    And input('#password', 'password')
    When submit().click("#kc-login")
    Then waitForUrl('http://localhost:8080/auth/realms/endpoint')

此 URL 包含我们要提取的值。 waitForUrl 等待此 URL 的到来,一旦收到此 URL 如何进行下一步。是否有可能以某种方式将其存储在某个变量中?正如我看到的所有演示一样,提到了输入或可以单击此 URL 上的按钮如何从 URL 中提取值呢?如何存储此 URL 以便提取值?

http://localhost:8080/auth/realms/endpoint?state=abbv&code=t6002231-3031-459f-b4c4-2e8a25223550.64f22bbc-6c28-49e4-bc2c-ca0ed40060de.36aee969-73e3-4bc5-bc5e -a4b68

请阅读文档。 waitForUrl()其实returns的值URL:https://github.com/karatelabs/karate/tree/master/karate-core#waitforurl

* def actualUrl = waitForUrl('/some/path')

另见 driver.urlhttps://github.com/karatelabs/karate/tree/master/karate-core#driverurl

* def actualUrl = driver.url