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:
- Retaiin Cookie after first login and use across.
- 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.
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
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.
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.
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
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,
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.
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.
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.
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.
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.
Yeah it’s a great forum, quite a few really nice people here