Search code examples
pythonpython-2.7seleniumselenium-webdriverrobotframework

close a browser by providing tear down only in robotframework


*** Settings ***

*** Test Cases ***
Browser Shutdown

*** Keywords ***
Browser Shutdown
    Close Browser

file closebrowser.txt contains no keyword error shown when run this file. I just want to execute this file at the end of all test cases so that if browser is open this will close that

in closebrowser.txt i dont want to execute any test, only tear down the browser(s) after executing all the test.txt file in the folder. Since i can add one or more test file in the folder (e.g. test3.txt,test4.txt...) so instead of providing in these file i want a separate file which will run and close the browser


Solution

  • Create _init_.txt file to each of the directories and add

    *** Settings ***
    Suite teardown    Close all browsers
    

    to the file. That will add suite teardown that will be run after any test suites in the directory. The _init_.txt is called an initialization file