Hi,
Im struggling with translating all my Selenium library based scripts to Browser library.
The recent subject is that I’m trying to get the titles of the pages I have opened in order to run an assertion.
‘@{Titles} = Browser.
Should Be Equal As Strings ${Titles[1]} Expected Title of Page’
Does anyone know how I can store the multiple title pages in an array and use indexing to confirm the title names are as expected?
Thank you in advance!
Hi Laurens,
it looks like Browser Library doesn’t have a keyword that gives you a list title’s directly.
You could however easily create one, it would probably look something like this:
Get Titles
# create a blank list
@{TitleList}= Create List
@{PageIDs}= Get Page Ids
FOR ${pageid} IN @{PageIDs}
Switch Page ${pageid}
${PageTitle}= Get Title
Append To List ${TitleList} ${PageTitle}
END
RETURN ${TitleList}
Append To List
comes from Collections Library so don’t forget to include that.
But if you just want to check the one page title you can simply just do:
@{PageIDs}= Get Page Ids
Switch Page ${pageid[1]}
${PageTitle}= Get Title
Should Be Equal As Strings ${PageTitle} Expected Title of Page’
Dave.
1 Like