Get page title(s) with Browser Library

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