By using our site, you acknowledge that you have read and understand our Cookie Policy , Privacy Policy , and our Terms of Service. I did answer the question. It would be better to split them up so your generated test results have clear reporting on the specific scenario being tested. One way could be by adding the expected success state as another parameter: I don’t think the approach OP was taking was the best one. Since the test method runs twice and both assert statements are running one test always passes and one test always fails.

Uploader: Kimi
Date Added: 10 November 2017
File Size: 34.50 Mb
Operating Systems: Windows NT/2000/XP/2003/2003/7/8/10 MacOS 10/X
Downloads: 55331
Price: Free* [*Free Regsitration Required]

If The Same parameter name is declared in both places; test level parameter will get preference over suit level parameter. JeffC, OP asking for solution not for suggestion.

Take it with a grain of salt, I don’t know the site you’re trying to run this against so I don’t know how it would work. In certain Selenium Automation Tests, there is a need to control keyboard or This would be a great use because your data provider could call the same hw with the min length, selejium length If you want to use multiple values for a parameter use DataProviders Parameters using Dataprovider Parameters annotation is easy but to test with multiple sets of data we need to use Data Provider.


Julian 8 They would fail on successful logins.

Dataprovider & TestNG XML: Parameterization in Selenium(Example)

I think I now understand better their usage. I’m trying to test the login functionality of a website. Though there is a way out. I would not use ho in this case and would write two separate tests, one for the bad login and another for the good login. In the following exampleWe check if method name is testMethodA.

You can have multiple different parameters, but each parameter can only have a single value. Here is the same test with suite level parameters NOTE: The way he’s got it set hhow is fine, he just needs to separate the test cases so the right one gets used with the right scenario.

But it is definitely achievable.

Thanks for the thorough response. A difference of opinion doesn’t warrant a downvote. I wasn’t the only one to “suggest” that OP’s approach wasn’t a good idea and yet you only downvoted mine? I want my first test case to provide invalid credentials with the first wegdriver of data that I defined in the DataProvider method.

java – Using Selenium WebDriver with TestNG and DataProviders – how to assert? – Stack Overflow

TestNG enables you to run test methods, test classes and test cases in parallel inside your What is Desired Capability? What is your exact requirement? I don’t think the approach OP was taking was the best one. To pass multiple data to the application at runtime, we need to parameterize our test scripts.



There’s not always one way to do things. You want to test multiple values of the same parameter using Testng.

I don’t think think checking valid and invalid logins should be just only be in two separate tests but separated in two groups. You may want to compare the actual length with the length reported.

He asked how to use different logins with the same code and webdrive r two asserts for the different cases. Let’s study them in detail – Parameters annotation with Testng.

How to Use the DataProvider in TestNG with a JAVA Example

You’re on the right track. Post as a guest Name. Sign up using Email and Password. Sign up or log in Sign up using Google.