Like selenium IDE how i can verify page title against static text
Hi,
you can try use this:
WebUI.openBrowser(āURLā)
WebUI.waitForPageLoad(5, FailureHandling.STOP_ON_FAILURE)
titleWindow = WebUI.getWindowTitle()
WebUI.verifyMatch(title, āExpectedTitleā, true)
It works, thanks Przemek
Hi Przemek,
I tried with above code but getting nothing from getWindowTitle() method.
I got below logs:
Unable to verify match between actual text āā and expected text āSalesforce - Enterprise Editionā using regular expression (Root cause: Actual text āā and expected text āSalesforce - Enterprise Editionā are not matched using regular expression)
Pls correct me where Iām lacking.
Iāve found the workaround by creating local variables for expected and actual results in particular et case⦠With Global variables I also always get the error specified above
By the way, I also found out that ig save all Global Variables to Default Execution Profile then error during execution, described by Vivek Kumar, doesnāt apper
Vivek Kumar said:
Hi Przemek,
I tried with above code but getting nothing from getWindowTitle() method.
I got below logs:
Unable to verify match between actual text āā and expected text āSalesforce - Enterprise Editionā using regular expression (Root cause: Actual text āā and expected text āSalesforce - Enterprise Editionā are not matched using regular expression)
Pls correct me where Iām lacking.
Hi,
This error is because the expression you want to verify (windows title) is NOT a regular expression. You musnāt use regex (this must be to false in the parameters of keyword verifyMatch)
Regards,
Joeyxx
To chime in, this should work just fine for you:
title = WebUI.getWindowTitle()
WebUI.verifyMatch(title, 'expectedPageTitleGoesHere', false)
That should get you what you are looking for to verify the Page Title.
getWindowTitle() does not always work for me. Iāve tried many things and I donāt know why sometimes it works and in other case it does not.
Iāve got the same call in two locations (one in a test case, the other in a function inside the Keywords file).
The one in the test case works, but the one in the Keywords file does not work as it always returns an empty String
The call is :
WebUI.verifyMatch(WebUI.getWindowTitle(), expectedTitle, false, FailureHandling.STOP_ON_FAILURE)
Iāve also tried using local variable and doing checks like this inside the Keyword function :
String windowTitle = WebUI.getWindowTitle()
println(windowTitle)ā¦
if (ā¦)
ā¦
I always get an empty String and the check fails
What I need actually is to be able to put the title in a variable because the window title gets the browser name appended to it, because Iād rather do something like
if (actualTitle.contains(expectedTitle))
KeywordUtil.markPassedā¦
else
KeywordUtil.markFailedā¦
instead of having to trim the actualTitle to remove the appended browser name or other String operationsā¦