getUrl returns the URL before the transition

Hi,
When I use WebUI.click 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?

WebUI.click(findTestObject('Object Repository/button')
WebUI.delay(10)
WebUI.verifyMatch(WebUI.getUrl(), 'https://sampleXXX', false)

I will do as follows

WebUI.click(findTestObject('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