How to handle failures in Test Suite in selenium webdriver - selenium

Suppose I have 10 test cases in my Test suite and when I execute the Test suite I get an error for test case no.7.
Now is there any way that I can restart my execution from test case no.7 after correcting the changes?
I'm using TestNG.
Do we have recovery scenarios in Selenium?

TestNG generates .xml configuration with failed tests http://testng.org/doc/documentation-main.html#rerunning
Or you can use org.testng.IRetryAnalyzer which runs failed tests again and you have more control over it.
Example here http://seleniumeasy.com/testng-tutorials/execute-only-failed-test-cases-using-iretryanalyzer.

Yes you can do that if you are using Eclipse IDE. Click on the arrow just before test class name, it will show you all the methods(test cases) of that test class. Right click on the one which you want to run. It will run that specific test only.

Related

Hot to print test summary after every test run

I am using Junit 5 and ant and i want to print junit test summary(number of tests passed/failed till now) after every test run.
Is there a way to do this?
The way to go is registering a test execution listener (see https://junit.org/junit5/docs/current/user-guide/#running-tests-listeners) and updating your own summary.

Execute Test Suite Without Refreshing Page in Selenium IDE

I'm trying to create a test case in Selenium IDE.
The idea is to split my whole test in smaller ones to help find problems in the execution.
Example of my test suite
I've created a test suite with all my small tests inside, and I'd like that the next test starts right where the last one stopped. But in the beginning of the execution, every test refreshes the browser.
Test Refreshing Browser on start of the execution
My question is:
Is it possible to run an entire test suite without refreshing the browser when a new test starts?
thanks a lot

How to know in which system test failed in parallel test execution?

I'm running 11 test scenarios on 3 different system all together parallely.
S1: Win7 Firefox46.0
S2: Win10 Chrome58.0
S3: Mac Safari9.0
After completion I can see the test failure in TestNG report but I can't track in which system the scenario is failed.
Is there any way so that I can track in which system or environment test failed.
How do yo execute the test cases? Do you do it in your build with CI-System, IDE?
On the selenium website https://github.com/SeleniumHQ/selenium/wiki/Grid2 is described how to surrender capabilities on the grid. You could deliver them as String variables and looking for their values in case of failing.
Maybe this could help you?
Using TestNG it can be very easy: Just put the browser name as a parameter into a data provider and print it in your stacktrace. It can be shortened like: "ch" for Chrome or "ff" for Firefox.
A control variable like can be useful for you if you decide to run a test case in another browser tommorow.

Selenium command level reporting using testNG

I’m new to Selenium WebDriver, Currently working on reporting testcases & test suits using TestNG (import org.testng.Reporter)on eclipse, At present TestNG produces high level reporting features for test cases ,methods & suites on test- output folder, similar to this --> http://testng.org/test-output/index.html.
I'm looking for a way to have following in the report created by testNG,
All selenium commands executed in my test method(s) should be displayed in index.html &
Failed screenshots for the relevant failure command with the reports, something similar to loggingSelenium ---> http://loggingselenium.sourceforge.net/samples/sampleResultSuccess.html
The reason I prefer this way is its easier, because this way I know exactly what selenium commands which were executed , I would have correct information what goes wrong, and when this occurs and the input parameters belong to specific selenium commands.
Is it possible in testNG?

Selenium Test Runner and variables problem

In my selenium test suite (html), I define a first test case to initialize variable called in the next test case.
Sample :
In first script :
store|//div[#id="myfield"]|myvar
In my second script :
type|${myvar}|myvalue
But when I start test runner (from maven), it returns an error telling that ${myvar} is not found
The value contained in the stored var is not used.
Any suggestion ?
Thans a lot
Maybe you could use cookies to store variable?
createCookie is in selenium and to read it you might use javascrpt(getEval)
As far as I know you cannot reference variables declared in a different test when running HTML suites.
What you need is Test and/or Suite "Setup" and "Teardown" functionality.
Test setup and teardown happen before and after each test. Suite setup and teardown only happen once, before and after the suite is run.
As you are using Maven, I assume that your development is in Java, so you could use JUnit
http://www.junit.org/
This has both test and suite setup and teardown:
Test Setup
http://kentbeck.github.com/junit/javadoc/latest/org/junit/Before.html
Test Teardown
http://kentbeck.github.com/junit/javadoc/latest/org/junit/After.html
Suite Setup
http://kentbeck.github.com/junit/javadoc/latest/org/junit/BeforeClass.html
Suite Teardown
http://kentbeck.github.com/junit/javadoc/latest/org/junit/AfterClass.html
I've created separate tests in Selenium IDE and then batched them in a test suite
After that ... when I ran them, the ${variable_name} stored in test 1 works fine in test 2.
Damien
The current version of selenium test runner doesn't pass variables from test to test like the IDE does. There is a javascript work around, check out Nick G's post on http://jira.openqa.org/browse/SEL-605