getUrl returns the URL before the transition

When I use to transition from screen A to screen B and use WebUI.getUrl, getUrl method returns the URL of screen A.
But what I expect is the URL of screen B.
So I usually use WebUI.delay(10) before use getUrl(waitForPageLoad is invalid in this situation).
Is there better way to get the URL of screen B?'Object Repository/button')
WebUI.verifyMatch(WebUI.getUrl(), 'https://sampleXXX', false)

I will do as follows'Object Repository/button')
WebUI.verifyElementPresent(findTestObject('selector to an element in screen B'), 30)
WebUI.verifyMatch(WebUI.getUrl(), 'https://sampleXXX', false)

This will finish as soon as screen B is responded. No need to wait for fixed seconds by WebUI.delay(10)

1 Like