I use a Maven project with Java, Selenium WebDriver, JUnit, and Serenity with Screenplay.
I have a login with a pop-up that only appears sometimes, how can I add a validation STEP for the pop-up without failing the whole TEST if the pop-up doesn't appear?
Put in the test, in try-catch waiting for the popup. If it will appear - make needed actions, then go to next step, if don't appear - then just go to the next steps.
Here is almost same question with good answer: Executing scenario even if one of the step is failed
Related
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 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
Is there a way to have eclipse show junit assertion errors (or more generally unhandled exceptions during testing for that matter) automatically without me going to the junit window, selecting the failed test, clicking the corresponding line on the right side, and then clicking the corresponding button each single time? This is ludicrous. There surely must be a better way I have not found yet!
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/
I am new to Selenium IDE. As far as I know, when open Selenium IDE, you will notice that the red 'record macro' button is toggled. This means that selenium will attempt to record every action you make inside the browser. This is a problematic way of recording as we implicitly wait for actions to complete before moving on.
If I only let Selenium to record every actions without specifying extra actions, many test step will be failed with error message : Element not found. I was trying to add extra actions based on Selenium API, like waitForElementPresent, waitForSearch etc.
My question is: How do I know which extra action do I need to add for each web target? Any standard for it? Thanks!
I use webdriver but I am familiar with IDE and so far I know it depends on your application how you want to handle the tests. If your application uses ajax calls you might need to use some frequent waitForElementPresent or waitForSearch etc.. and Assertions also depend on the needs of your tests.
Now, the question is how do you know which extra step do you need to insert?
Ans. is you will know the necessity. Such as, if your test step depends on a previous ajax call to finish then you know there is a wait necessary and you know what to do. Not to mention, you can always insert extra steps and I am sure you already know that. And, there is no standard for using those. You adjust your tests depending on your necessity
you need to go through introduction to selenium ide or just think straight this way that if any action needs loading of page, you simple need to wait for element present and the perform click
click|target|
waitForElementPresent|target|
or if you need to store any value you can use
storeEval|target|value
also the variable name in the selenium ide is named followed by $variableName
enter can be performed as ${KEY_ENTER}
to verify any value we can use AssertValue or VerifyValue
the difference between assert and verify is that assert stops the execution of test case if the value is false whereas verify gives error and execute next statement.
these are few points to be noted in selenium ide.
hope this answer would help you!
You may want to try Implicit Wait addon for Selenium IDE. It will automatically call WaitForElementPresent before executing actions on that element (like clicks). This may save you some time.
Here is the link of Selenium API, all actions can be found here.