Selenium - Individually passes, TestSuite didn't - java

I have an automated test about changing frame to a PDF viewer to read the text. I have four tests which basically do the same: Look for a number, letter... and finally test that a word does not exist in the PDF. If I run these test individually, or all frame related test, it works well. But if I run the test suite (which includes like 500 test). One of them systematically fails every time, showing me this error:
org.openqa.selenium.NoSuchFrameException: no such frame
I'm using try/catch, thread/sleep... and all my test are working good, but I cannot figure out why it's always the same test which fails, and why if i run it individually or all the feature, it works. Just wondering if you guys can show me different reasons why this could happen, so I can improve my skills.

Does your test suite take screenshots if the test fails? If it doesn't, I would encourage you to implement a rule for it. (there are numerous examples over the web). A screenshot could shed some light into what is going on.
It sounds like a performance issue though. When you run 1 test, there just isn't a lot of load on the system, and the frame is loaded fast enough for the test to locate it.
However, when you add in the whole suite, tests can sometimes run slower and steps could fail as a result.
It's possible that the failing step is the previous step. If the frame is supposed to load after clicking something, but the click action took place before the link was fully loaded (the link was not actually clicked), then the frame won't be there and the test fails.
It wouldn't matter how long the failing step waited as the previous step was really the one that failed

Related

JUNIT 5 report collapsing automatically

When I'm running my tests on JUNIT 5, its report automatically collapses between one parameterized test and another during execution:
For example, when the 1st Device is running, the run report is opened like that. When the first test finishes and goes to the second run, all these lines collapses and I need to right-click the "TestCases" at the top and click on "Expand All" option.
Not sure if this is clear, I wish I could record a gif, but I'd like to know if there is an option to JUNIT do not collapse the executions automatically, because sometimes I want to follow the execution in real-time and see if any of the tests got an error, and not just at the end of the execution.
JUnit is just sending out „events“ to your IDE about tests being started and finished. JUnit has no control over how the IDE will animate this stream of events.
So I recommend that you open a feature request for your IDE vendor.

I want to generate a UI which allows me to select and deselect my Test Cases and Run the selected test cases (Test Developer)

I've plenty of test cases, say 100. when i want to run my regression/smoke tests i can do that by dividing those in groups and running the testng.xml file.. but my wish is to create a UI which have the test case names,browsers.when i want to run 2-3 test cases, i'll just run select the test cases and browsers and then click on 'Run'(A button in my UI). so it'll interact with testng.xml and then send values to it. so indirectly i want to edit the testng.xml file and then run the testsuite. Anyone can help me out in this COntext or give me links of some online tutorial or anything from which i can get help ?
I use Eclipse, Cucumber and tags to do this.

TestNG Overriding Report Generation

At the end of the TestNG run, we have a couple things that I am noticing are happening.
We get the following message displayed on the console (this example shown with failing tests):
53 tests completed, 6 failed, 1 skipped
There were failing tests. See the results at: file:///Users/***/Workspace/***/build/test-results/
And, of course an HTML report is generated. What I would like to do, is to add a step to this process where we are copying the generated HTML reports to a different server on the same network, and also publishing a notification in Slack. I think the slack part is pretty easy, just sending in a HTTP request with a json body, but where would I put the code to do this? Can I even do this without having to recompile TestNG?
You just have to implement your own reporter: http://testng.org/doc/documentation-main.html#logging-reporters
Dont understand your question completely .
" but where would I put the code to do this?"
At the end i suppose. You can implement your Listener and then in onFinish method you can implement the copying part.
Or
you can do the copying at the end after testng run is complete. How are you running testng tests ? That will be important in that case.

Using the same Firefox Window to run multiple tests in Selenium WebDriver (Java)

I am running test cases on selenium Webdriver in Java. The first test case opens the browser window and performs the test.
After the first test case is complete I want to utilize the same browser window to run the next set of multiple test cases.
How can this be achieved? Can someone point me in right direction?
Don't quit your browser in the "TearDown" part.
Navigate to a common URL in the "TearDown" part from where multiple test cases can start.
Thus you will be able to utilize the same browser window to run the next set of multiple test cases.
You can reuse a browser in multiple tests using Spring to inject it. This can be faster for running a suite. But, and it's a big but, if one tests "dirties" the browser (e.g. with cookies), then you could easily find yourself spending more time debugging flaky tests that you save on run time.
There's an example here: http://www.alexecollins.com/tutorial-integration-testing-selenium-part-1/

How to get a list of the lines of code run during an execution?

I've tried to search for this topic but I haven't found what I'm looking for, it could be that my terminology is off however. I'm writing Java and coding in Eclipse Luna.
I currently have a program, and a set of tests related to that program that will produce a pass/fail result for each. What I'm looking for is the ability to run one of these tests and retrieve a list of the lines of code (both in the test file and the actual program) that has been executed at some point during the test. What methods can be used to accomplish this? The idea is to use that list later for fault localization if a test failed.

Categories