Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close the new tab and return to the first tab in Robot Framework?

My test scenario clicks the button that follows to the new tab of the browser, after verifying that we got the right page I need to close this tab and return to the first tab. How could I close the actual tab? I tried to use Close Window, but it closes the entire browser?

like image 821
Сергей Подопригора Avatar asked Jan 27 '23 11:01

Сергей Подопригора


2 Answers

This code can help you open new tab and close that's new tab by and return to your first tab.

*** Test Cases ***
T1
    Open Browser    ${URL}   ${BROWSER}
    click element   name=btn
    ${title_var}        Get Window Titles
    Select Window       title=@{title_var}[1]       
    close window
like image 89
Sidara KEO Avatar answered Apr 08 '23 04:04

Sidara KEO


you can use below code to close active window and back to main window

${windowhandles}= Get Window Handles

Switch Window ${windowhandles}[1]

close window

Switch Window ${windowhandles}[0]

like image 39
user16413142 Avatar answered Apr 08 '23 04:04

user16413142