How to get path to UITestActionLog.html from code

落爺英雄遲暮 提交于 2019-12-02 14:56:37

问题


Each test case saves results to a separate UITestActionLog.html file. But in the end of each test case I'd like to move that .html to a different folder and rename it.

Is it possible to do so in, say, [TestCleanup()]? If yes, then how can I programmatically get .html report location?


回答1:


The TestContext class contains several fields with "directory" in their names. These can be used to access the various directories associated with running the tests.

As well as managing the files as asked by your question the TestContext class has an AddResultFile method. The Microsoft documentation on this mehod is not clear, but it seems that the files are saved for failing tests and discarded for passing tests.




回答2:


To get the directory in which the UITestActionLog file will be located, use the TestContext.TestResultsDirectory Property. You can use below code to get the full path:

string fullPath = TestContext.TestResultsDirectory +"\" +"UITestActionLog.html";


来源:https://stackoverflow.com/questions/19682034/how-to-get-path-to-uitestactionlog-html-from-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!