Archive for September, 2013

Posted by Denno Secqtinstien in Java, Selenium, Testing. Comments Off on How to create test suite using Junit and eclipse in selenium

How to create test suite using Junit and eclipse in selenium

There are some scenarios where we need to run multiple test cases. Either we can run those test cases independently or together. But there are some real time cases where we need to run our test cases in a particular order. In this case we would prefer Test Suite to combine the test cases together and decide their orders and run those.

Below are the steps

1. Create a Test Suite class where we create the Test Suites which will call all the test cases in a particular order.

Like this:

Upgrading Selenium Standalone Server

I have started writing this blog from 3 months. When I have started writing the latest Selenium Standalone Server version available for download was 2.31.0.

Now I would like to check if there are any latest version available by following the below steps:

1. Open www.seleniumhq.org
2. Click on ‘Download’ tab to navigate to the downloads page as shown below:

3. In the Download page, view the latest version of the Selenium Standalone Server as shown below:

4. I’ve observed that there is a new version 2.32.0 for Selenium Server available for me to download (currently I and using 2.31.0 version). So I would like to upgrade it to the latest version by following the below steps.

Upgrading to the Latest Selenium Server:Pre-requisite: Ensure that Selenium Standalone Server is not running. If it is running, just restart the Eclipse IDE to stop it.

1. Download the Selenium Servers new version 2.32.0 and place the downloaded file in any folder as shown below:

2. In Eclipse IDE, Right click on the Project you are working with and select ‘Properties’ option as shown below:

3. Ensure that ‘Properties for Project’ dialog is displayed, select the older version of Selenium Server and click on ‘Remove’ button as shown below:

4. Ensure that the older version of Selenium Server is removed and click on ‘OK’ button as shown below:

5. Expand the libraries folder, right click on the older version of Selenium Server and click on ‘Delete’ option as shown below:

6. Click on ‘OK’ Button on the ‘Confirmation’ dialog as shown below:

7. Ensure that the older version got deleted from the libraries folder
8. Copy the latest version as shown below:

9. Paste the copied latest version into the libraries folder as shown below:

Rate this:

Share this:

Like this:

Posted by Denno Secqtinstien in Java, Selenium, Testing. Comments Off on Only one test should be written inside a test method

Only one test should be written inside a test method

1. Before going forward, lets once again view the code we have written in our previous post below: (i.e. The code with more than one tests inside a single test method)

2. As its not a good idea to write more than one tests inside a single test method, lets Refactor the Selenium Automation code by writing all the 3 tests into a separate test methods as shown below:

3. Start the Selenium Standalone Server
4. Save and Run the ‘Class16.java’ file by selecting the ‘JUnit Test’ option
5. In this case, Observe that the Firefox Browser has launched and closed for 3 times instead of once, for performing the above three tests as shown in the below video.

Click here to download this project and import into Eclipse IDE on your machine.

Why did the firefox launched and closed separately for each test method in the code ?

As we’ve three tests and we’ve written test method for each of our tests, hence we got 3 test methods in the Selenium Automation code. But in this case ‘chapter1’ page is common for 3 of the tests and hence its not required to close the application and launch it for performing the remaining tests. This has happened because of @Before and @After JUnit annotations.

The code inside the @Before and @After annotations will be executed once for each test method in our Selenium Automation code. Since we’ve three test methods in our code, the methods under the @Before and @After got executed thrice (i.e. once for each test method).

How to resolve this problem ?

Suppose if we want to run the methods under the @Before and @After annotations only once, we’ve to replace these annotations with @BeforeClass and @AfterClass. (i.e. The method under @BeforeClass will be executed before executing all the test methods inside the class and The method under @AfterClass will be executed after executing all the test methods inside the class.

So to conclude the executing process will be as shown in the below screenshots:

@Before and @After:

@BeforeClass and @AfterClass:

You can research for implementation for the @BeforeClass and @AfterClass Annotations as well for confirmation.

Rate this:

Share this:

Like this:

Posted by Denno Secqtinstien in Java, Selenium, Testing. Comments Off on How to Start IE9 using Selenium RC in Windows Vista or Windows 7

Selenium RC – How to Start IE9 using Selenium RC in Windows Vista or Windows 7

Issue:

When I started to work on the Selenium RC, it was running the tests against IE6 and that makes sense if the tests were written 3 years ago and code was never updated since then. Now the challenge here is to run all the tests of the projects I was working on, in Windows 7 machine instead of WinServer 2003 and running the tests against IE9 instead of IE 6.

Solution:

There are couple of simple solutions you can try to get these things done and working properly in your new environment.

1. Check your Server version. If you are using very old selenium version then its the time to get the latest Selenium Server from the Selenium Website.

2. Command Prompt. You will also have to make sure that the command prompt you are working on to run the Selenium Server is opened as “Run as Administrator“. This is one of the reasons that you might not be able to open IE latest version with Windows Vista and Windows 7 i.e. IE9.

3. Disable Protected Mode. This is an alternative trick to solve the issue and run the tests against IE9. You will have to go to IE | Internet Options | Security | Enable Protected Mode and then Uncheck the box and click on Apply and Ok. That is it and it will resolve the issue. Please go to my other blog where I have mentioned everything step by step how to do this.

Now we are good to go and run our tests against IE7, IE8, IE9 with either Windows Vista or Windows7.

Rate this:

Share this:

Like this:

Posted by Denno Secqtinstien in Java, Selenium, Testing. Comments Off on How to do database testing using selenium rc

How to do database testing using selenium rc?

There are no selenium specific commands to do the database testing. But, you have the work around with native language. Here is the example how you can make database testing in selenium. The below mentioned commands will help you to begin with.

Before you use the below code You should have created the DSN name for MS SQL Server DB or Oracle DB using ODBC drivers. Here the name that we have used for the database DSN name is QT_Flight32. And the table in that database we are using is Orders. Hope the remaining steps you can easily understand.

//KEEP THE NAME OF THE PACKAGE
package com.src.test;

//IMPORT THE SQL PACKAGE
import java.sql.* ;

//DECLARE THE CLASS
class JDBCODBCTestCase
{

//WRITE THE MAIN METHOD TO CONNECT TO THE DATABASE
public static void main( String args[] )
{