简体   繁体   中英

How to execute testng test cases with shared webdriver?

I want to report each step of my selenium test case in HP ALM. Reporting has to be done in parallel with execution ie after 1st step is executed it has to be reported in ALM and so on. I am writing status of each test case as pass/fail in excel file which in turn reported in ALM.

I have made seperate classes for each step and tried executing each step in command prompt using testng.xml file The command used is:

java -cp “.\bin;.\libs\*” org.testng.TestNG -testnames “Login” testng.xml

This executes the first step successfully and return the output as pass/fail in my excel file.

Now when I execute 2nd step (as second class) it will again run @BeforeSuite Method which creates a separate instance of browser which I don't want as I want to proceed from that particular point where my 1st step completed.

Note: I created a separate class for Browser Initialisation and declared my webdriver static (initialised in @BeforeSuite ) and inherit my test cases from this class so that webdriver is shared among all.

My requirement in brief is to run test cases one by one (not as a complete suite) with webdriver instance shared among all the test cases.

I apologize for not putting my code as it is client specific. Thanks in advance.

Actually, there is a Bumblebee product from Agiletestware which contains java annotation package which can be used together with TestNG and Selenium WebDriver to report test case result to HP ALM. It even can upload a screenshot of failed test case to ALM.

Please see the docs: https://www.agiletestware.com/docs/bumblebee-docs/en/latest/qa-frameworks/selenium-webdriver/

Disclaimer: I'm a Bumblebee developer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM