Am a beginner in Selenium and am trying to learn selenium on my own by googling. One thing which I noticed was in many of the posts which I read about selenium the name of the framework by name "TestNG" is common. I have understood that its a framework and with its Annotations and Test case compliance power, we can organize our Selenium test cases using the TestNG. But I have few queries regarding the same:

  • By using the TestNG framework, should we modify the Selenium Code which we write?
  • Are there any Coding standards which has to be mandatory used while using TestNG?

Please, do clarify my doubts. And even recommend some of the blogs/sites from where I can learn Selenium as a beginner.

  • TestNG is a test execution engine - the part that identifies methods as test cases and executes them, similar to the other ones MichaelF mentioned below. Other common ones are all of the xUnit frameworks, so JUnit is another common one for code written in Java. – Sam Woods Apr 22 '14 at 0:09

I have used Selenium and TestNG in the past to manage a lot of my automation and as Siva mentioned you do have the basics down. While TestNG is one of the most common Frameworks out there, it is not the only one, and you can use whatever one works for you. So long as you can import the Selenium drivers you can use any framework in which you are familiar, I've used Gallio, TestNG, PowerShell, Fitnesse/Fitnium as a wrapper and even Python/Robot to drive the tests. Find which one works for you.

Look for a way to organize your tests that make sense to you and your Users, I have added SpecFlow on top of my Test Cases to make the higher level descriptions more readable to Business Users. This allowed me to code with Selenium/Web Driver behind the scenes and do the kind of testing I wanted, while presenting a readable set of Test Cases to my Users.

As to your questions:

  1. You should not need to modify your code while using TestNG, although it depends on what features of TestNG you take advantage of; you probably could though I didn't when I originally set up my framework.
  2. Coding Standards I tend to think of as being specific to your company, if you don't already have some standards then check with your developers and see if you can co-opt theirs this way you have a standard across departments. Code then looks the same in your organization and it is easy for anyone to review, or even give your test code a code review - which you should do anyway.

There are plenty of places to learn, but it depends on your level of expertise. Check the examples at the Selenium site first, then if you feel comfortable you can look for more.

| improve this answer | |

You seem to have picked up basics correctly. I can add my inputs

Selenium is mainly for web test automation. Predominantly you will simulate user actions on the website. The code generated by IDE need to be modified to make it data driven / organizing test scenarios etc

If you are going to write automation code (you need to manage input data handling, pre-test execution, post test execution, tracking errors / failures etc). TestNG framework provides all the above listed features by itself reducing your effort to reinvent the wheel.

Refer basic examples from testng.org, seleniumtests.com.

This forum can provide lot more useful pointers / specific help if you run into issues.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.