[英]How to execute testng test cases with shared webdriver?
I want to report each step of my selenium test case in HP ALM. 我想报告我在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.
报告必须与执行并行进行,即在执行第一步后,必须在ALM中进行报告,依此类推。 I am writing status of each test case as pass/fail in excel file which in turn reported in ALM.
我在excel文件中将每个测试用例的状态写为通过/失败,然后在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: 我为每个步骤制作了单独的类,并尝试使用testng.xml文件在命令提示符下执行每个步骤。使用的命令是:
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. 这将成功执行第一步,并在我的excel文件中将输出作为通过/失败返回。
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. 现在,当我执行第二步(作为第二类)时,它将再次运行
@BeforeSuite
方法,该方法创建了一个我不想使用的浏览器实例,因为我想从完成第一步的特定点继续进行。
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. 注意:我为浏览器初始化创建了一个单独的类,并声明了我的webdriver静态(在
@BeforeSuite
初始化),并从该类继承我的测试用例,以便在所有驱动程序之间共享webdriver。
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. 简而言之,我的要求是在所有测试用例之间共享一个webdriver实例的情况下,一个接一个地运行测试用例(而不是一个完整的套件)。
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. 实际上,有一个来自Agiletestware的Bumblebee产品,其中包含Java注释包,可以与TestNG和Selenium WebDriver一起使用,以向HP ALM报告测试用例结果。 It even can upload a screenshot of failed test case to ALM.
它甚至可以将失败的测试用例的屏幕快照上传到ALM。
Please see the docs: https://www.agiletestware.com/docs/bumblebee-docs/en/latest/qa-frameworks/selenium-webdriver/ 请参阅文档: https : //www.agiletestware.com/docs/bumblebee-docs/en/latest/qa-frameworks/selenium-webdriver/
Disclaimer: I'm a Bumblebee developer. 免责声明:我是Bumblebee开发人员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.