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

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.

Related

How to handle failures in Test Suite in selenium webdriver

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.

Running the same junit test case using selenium webdriver in multiple instances of the same browser (load testing)

I'm trying to simulate a firefox load testing situation. I want my to test how 10 simultaneous logins would play out on my system. I already have a connected selenium grid hub and 10 open nodes.
So far, I know I can write the test case and run it 10 times which isn't what I need because it isn't automated. I also know that I can use invocation count on the test to make it run as many times as i want but this only works on the same browser node.
Does anyone have any ideas on how to automatically distribute the same test case to multiple instances of the same driver profile?
i.e. Run a login case test times on the same firefox profile open in 10 different nodes in parallel.
Gracias!
P.S. I built my tests using testNG if that matters.
Basically selenium and testNG is not for such requiurement. You should use some dedicated tool for that like jmeter.
However you can run n methods parrallel let say if you want to login with 10 dif user in 10 thread/browser you can create test data driven and configure to run method in parrallel. Make sure you are providing proper value of parrallel thread count.
How about combining threadpoolsize with invocationcount. - http://testng.org/doc/documentation-main.html#parallel-running
Grid would take care to distribute on the 10 nodes.
use headless browser like GHOST and then invoke multiple threads as ghost has no UI so it would work in your case

Intellij running one test in TestNG

So my typical workflow is
I write a data driven test using TestNG in IntelliJ.
I supply hundreds of data items
Run the test and one or two of them fail
I see the list of passed/failed tests in the "Run" pane.
I would like the ability to just right click that "instance" of the test and run that test alone (with breakpoints). Currently IntelliJ does not seem to have that feature. I would have to right click the test and when I run, it runs the whole set of tests with hundreds of data points.
Is this possible?
TestNG supports this at the testng.xml level, where you can specify which indices of your data provider should be used. It's called "invocation-numbers" and you can see what it looks like by running a test with a data provider, failing some of its invocation numbers and looking at the testng-failed.xml that gets generated.
Back to your question: your IDE needs to support this feature in order to make it available in the UI, so I suggest you ask on the IDEA forums
The feature has been added as of Intellij 142.1217: https://youtrack.jetbrains.com/issue/IDEA-57906

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