Tag Info

New answers tagged

3

The answer provided by Sam nearly worked for me, but still had some problems as described above. Basically I needed to use TestRule instead of MethodRule, and TestWatcher() instead of TestWatchman() - since the former ones have been depreciated. I also needed to pass in "Description" instead of "FrameworkMethod" to get the name. Finally I need to ...


3

You can use the TestWatchman class which is part of JUnit to get the test case name, as well as the status, so you could take screenshots only on failure. Here's an example that takes a screenshot on failure: @Rule MethodRule watchman = new TestWatchman(){ @Override public void failed(Throwable e, FrameworkMethod method){ File scrFile = ...


0

The command should be: captureEntireScreenhot which is available in commands and the target should be the address of the folder where the screenshot is to be saved. This has to be written manually. Example as requested. WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com/"); File scrFile = ...



Top 50 recent answers are included