AutoTester213
AutoTester213

Reputation: 2871

RobotFramework - Handle 2 Browser tabs at the same time and test them

I have this problem where i need to test a functionality of my web app with 2 tabs open and check if I update someting on tab 1 Tab 2 refreshes, I am trying to get this done using the Press key keyword.

I am targeting the body of and Using the Ascii number for CTRL+T to open a new tab, A new browser window opens rather than a New Tab i am using latests version of Chrome.

I have also tried to to use \\09 but that gives me the same result

Press Key  tag=body   \\20

Then i try to go back to the window using the Select Window MAIN Keyword but that doesn't work.

QUESTION: how can i open 2 tabs at the same time and test them using RobotFramework with SeleniumLibrary?

Upvotes: 2

Views: 4655

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386342

I think your test would be just as valid with two windows as it would with one window and two tabs.

You can call the open browser keyword multiple times, giving each window its own unique alias. You can then switch between them with the switch browser keyword and the appropriate alias.

Example

*** Settings ***
Library  SeleniumLibrary

Suite Teardown  close all browsers

*** Variables ***
${browser}  chrome

*** Test cases ***
Example using two windows
    open browser  http://www.example.com  ${browser}  alias=tab1
    open browser  http://www.w3c.org      ${browser}  alias=tab2

    switch browser  tab1
    location should be  http://www.example.com/

    switch browser  tab2
    location should be  https://www.w3.org/

Upvotes: 7

Related Questions