Is it possible to run test suites in a way that you only open Browser once

I am testing a Webportal which has a Muti Factor Authentication. And I do not want webdriver to open a new browser everytime a new feature/Test Suite is executed. In order to do this there are only two options:

  1. Retaiin Cookie after first login and use across.
  2. Create a Test Suite Master file like TestNgXml file where you open browser once and run all your test suites.

However I am not able to implement either of them, so I am open for suggestions.

Hi KP,

Suite setup and teardown and Test setup and teardown are what you re probably after, it would probably look something like:

  • suite setup - open browser and login
  • test setup - go to main (home?) page so all tests can start from a known point
  • test cases
    • test a
    • test b
    • test c
    • test n
  • suite teardown - close browser

Dave.

Hi Dave,
Thank you for your response. I do understand Suite setup and teardown, but do we have a keyword to control multiple Test suites , example you create a master robotfile and include all your test suites you want to run inside this main robot file. It is similar of having a XML files in Test NG where you can use include tag and then you define all the different test scripts you want to execute.
I am looking for similar solution because today it is difficult for me to put all my tests in a single Test suite.

Hi KP,

I think you’d need to put the suite setup and teardown in the master robot file, I’m not so sure, bust give it a try and experiment I guess.

Dave.

I am struggling to create the robot master file. Please have a look into below from TestNG.

In this way you can run/configure multiple suites inside a single file. Is it possible to do same with robotframework? (Not directly in command line or using Tags.)

A typical suite XML file is given below:

incas eif XML code is not visible please have a look into url- TestNG - Run Tests and Suites using Maven - HowToDoInJava

Hi KP,

I don’t use TestNG but I get the idea I think,

In robot framework, you can include resource files, which are just robot files without any test cases section.(can be called .resource or .robot it doesn’t matter

You can have “master” robot files that only have test cases and a settings section with a resource line to import the file(s)

You can also have multiple robot files with test cases in a folder or even a folder structure and then tell robot to run all tests in that folder (see Specifying test data to be executed )

when using the folder method you can also have a Suite initialization files

Then all those can be combined.

Hopefully that explains what your after,

Dave.

Thank you for clarification Dave. Only challenge with this approach is, I still have to write all my tests in a sigle file. I was looking for a solution where I can import tests written in “.robot” files to a single file and not to import them as Resource files.

Hi KP,

No with the folder approach you can have a few test cases in each file, just put them all in the same folder and when you run robot, you give the path to the folder instead of the path to a single robot file, then all the .robot files in that folder will be run.

i guess you can say the folder becomes the master test case file and there’s is no special import syntax, just being in the folder means it’s imported - makes it easy to see.

Dave.

Yes you are right, putting all tests in a folder is a good approach but then the main challenge I have today is that I cannot open Browser once and skip multi factor authentication for other tests.
Another aproach would be that I do not close browser after 1st test suite execution and use “Go to” key word. I am not sure if it is possible to define sequence for test suite, so that the test suite with open browser is executed first.

Hi KP,

That’s why I mentioned the __init__.robot file, use a Suite Setup in that file to open the browser and do the MFA and a Suite Teardown in that file to close the browser.

Dave.

1 Like

Sure, this sounds like a good approach. Thank you.
I am also really impressed with this community forum; I am getting help even on weekends. Thank you for your support.

Hi KP,

Yeah it’s a great forum, quite a few really nice people here :+1:

Dave.

2 Likes