This framework is developed using ANT, TestNG, JUnit and Selenium. Using this framework, a user is able to create an automated test case, which can be run later by executing a single command. This framework uses different frameworks are as follows:
Selenium: This framework is needed for recording a testcase, exporting it into Java, and executing it on a browser
TestNG: This framework is used to organize different tests, and to report results.
ANT: provides the glue to hold everything together, and execute basic commands.
JUnit: This framework is used only for reports i.e JUnit Reports.
This framework has one testsuite called ApplicationTestsuite and thisi is java class which extends BaseSeleneseTestsuite that in turn extends SeleneseTestCase that does the required setup and teardown.
· ApplicationTestsuite .java: This test logs into the your application console using the username/password. It has only methods and each method is one testcase.
. BaseSeleneseTestsuit.java: This class has two methods setup() and tearDown(). Setup() method is used for setting up the environment meaning creating selenium instance and launching the browser to test and other method is tear down which is mainly for stopping the selenium and killing the browser.
The folder structure or contents of SeleniumTestFramework.zip of this framework is as follows:
|----------SeleniumTestFramework
|-------config
|-------lib
|-------test-src
|-------build.xml
|-------config.properties
|-------test-output
|-------build
· The config directory contains testng.xml file, and is a place holder for configuration files.
· The lib directory contains required jar files, and is a place holder for other library jars/zips.
· The test directory contains test java files and is a place holder for other test files.
Once the tests are run, build and test-output directories will be created.
· The config.properties is properties file.
· The build.xml file is taking care of starting selenium server, compiling testcases and running the testsuite.
· The build directory contains compiled classes, and is a volatile directory that is deleted by the target clean in build.xml file.
. The test-output directory contains result files, and is generated by TestNG.
Record a testcase using Selenium IDE (Firefox browser only), Export the test case into Java as mentioned below steps.
· Open the website you’d like to test in Firefox browser
· Start the selenium IDE from your Firefox browser:Tools ->Selenium IDE
· Ensure that the Base URL in Firefox is the same as the website you want to test
· Start clicking on the website. Selenium will record your actions.
· When finished, do: File -> Export Test As. -> Java – Selenium RC and save the java file.
The saved java will have one mehod called testNew(), this method will be the one test case.You can create a new java file (Testsuite) and add the testcase to new file or you can add the test case to existing the java file (Testsuite).
- Follow the below mentioned steps to add the test case to the existing framework or testsuite.
· Copy the testNew() method to existing testsuite(java file) i.e either ApplicationTestsuite.java based on the category.
· Rename the testNew() method to appropriate or meaningful name.
· Add the method level Annotation to the method (testcase) using TestNG. Annotations are mainy used for adding the testcase to a particular group and sequence to run the testcase.
- Follow the below mentioned steps to add the test case to new Testsuite (Java file)of the framework.
- Write new Java file called NewTestsuite.java and extend the BaseSeleneseTestsuiteclass.
- Add the generated testNew() method to existing testsuite(java file) to NewTestsuite.java
- Rename the testNew() method to appropriate or meaningful name.
- Add the method level Annotation to the method (testcase) using TestNG.
- Annotations are mainy used for adding the testcase to a particular group and sequence to run the testcase.
- Make a entry of this new testsuite (NewTestsuite) to config/testing.xml.
Follow the below steps to run the Automated test suite
- Edit the “config.properties” file to mention application URL, browser type and application user name and password.
- Open the command prompt and go to extracted directory, e.g: c:/ SeleniumTestFramework
- Set JAVA_HOME and ANT_HOME
- Execute the command: “ant” from ‘SeleniumTestFramework’.
- You should see the Selenium server window and new browser window open up, and run through your testsuit.
· Reports:
This framework generates both Junit and TestNG Reports. Check reports generated by TestNG and JUnit under ‘SeleniumTestFramework/test-output’ directory.
Download the selenium-rc from here and testng from here.
- BaseSeleneseTestsuite.java
Please find the Java files and the build.xml which is required for this framework. I couldn't upload the file
package com.example.selenese.tests;
import java.util.Properties;
import java.io.File;
import java.io.FileInputStream;
import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import java.util.regex.Pattern;
@Test(sequential = true)
public class BaseSeleneseTestsuite extends SeleneseTestCase {
public static Selenium selenium;
public static String TIMEOUT_PERIOD ="60000";
public static String APP_USER_NAME;
public static String APP_USER_PASSWD;
public static String strPath;
public String APP_URL;
public String BROWSER_TYPE;
@BeforeSuite(alwaysRun = true)
public void setUp() {
try{
//strPath = System.getProperty("user.dir");
Properties properties = new Properties();
properties.load(new FileInputStream(new File("config.properties")));
APP_USER_NAME = properties.getProperty("APP_USER_NAME").trim();
APP_USER_PASSWD = properties.getProperty("APP_USER_PASSWD").trim();
APP_URL = properties.getProperty("APP_URL").trim();
BROWSER_TYPE = properties.getProperty("BROWSER_TYPE").trim();
System.out.println("The APP_USER_NAME is : "+APP_USER_NAME);
System.out.println("The APP_USER_PASSWD is : "+APP_USER_PASSWD);
System.out.println("The APP_URL is : "+APP_URL);
System.out.println("The BROWSER_TYPE is : "+BROWSER_TYPE);
BROWSER_TYPE="*"+BROWSER_TYPE;
}catch(Exception e){
e.printStackTrace();
}
selenium = new DefaultSelenium("localhost", 4444, BROWSER_TYPE, APP_URL);
selenium.start();
selenium.setSpeed("500");
selenium.setTimeout(TIMEOUT_PERIOD);
selenium.windowMaximize();
}
@AfterSuite(alwaysRun = true)
public void tearDown() {
try {
checkForVerificationErrors();
} finally {
selenium.stop();
}
}
}
- ApplicationTestsuite.java
import java.util.Properties;
import java.io.File;
import java.io.FileInputStream;
import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import java.util.regex.Pattern;
@Test(sequential = true)
public class ApplicationTestsuite extends BaseSeleneseTestsuite {
@Test(groups = {"initGoup"})
public void testAppLogin() throws Exception {
try {
selenium.open("/ccore/Login.jsp");
selenium.type("j_username", APP_USER_NAME);
selenium.type("j_password", APP_USER_PASSWD);
selenium.click("button1");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
checkForVerificationErrors();
}
finally {
clearVerificationErrors();
}
}
@AfterClass(alwaysRun = true)
public void testAppLogout() throws Exception {
try {
selenium.selectFrame("relative=up");
selenium.selectFrame("top");
selenium.click("//font");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
checkForVerificationErrors();
}
finally {
clearVerificationErrors();
}
}
@Test(dependsOnMethods="testAppLogin",groups = { "initGoup" })
public void testAddGateway() throws Exception {
try {
selenium.selectFrame("relative=up");
selenium.selectFrame("body");
selenium.click("//input[@value='Add New Component']");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.type("name", "testGateway");
selenium.type("url", "http://localhost:9700/gateway");
selenium.click("button1");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.click("//input[@value=' Ok ']");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
checkForVerificationErrors();
}
finally {
clearVerificationErrors();
}
}
@Test(alwaysRun=true,dependsOnMethods="testAddGateway",groups = { "initGoup" })
public void testRegisterService() throws Exception {
try {
selenium.selectFrame("relative=up");
selenium.selectFrame("menu");
selenium.click("link=Policy Management");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.click("link=Register Services");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.selectFrame("relative=up");
selenium.selectFrame("body");
selenium.click("link=Services");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.click("//input[@name='Submit' and @value='Add New Service']");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.type("serviceName", "CRSrv");
selenium.type("serviceVersion", "1.0");
selenium.type("wsdlUrl", "http://localhost:9700/orabpel/default/CreditRatingService/1.0/CreditRatingService?wsdl");
selenium.click("submit");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.click("//input[@value='Finish']");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.click("//input[@value=' Ok ']");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.click("link=commit");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.click("//input[@value=' Ok ']");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
checkForVerificationErrors();
}
finally {
clearVerificationErrors();
}
}
@Test(alwaysRun=true,dependsOnMethods="testRegisterService",dependsOnGroups = { "initGoup" },groups = {"nextGroup"})
public void testGatewayCheck() throws Exception {
try {
selenium.selectFrame("relative=up");
selenium.selectFrame("menu");
selenium.click("link=Tools");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.click("link=Test Page");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.selectFrame("relative=up");
selenium.selectFrame("body");
selenium.type("wsdl", "http://localhost:9700/gateway/services/SID0003001?wsdl");
selenium.click("wsdlURL");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
selenium.type("ora_testpage_process_part_payload", "12345");
selenium.click("invoke");
selenium.waitForPageToLoad(TIMEOUT_PERIOD);
checkForVerificationErrors();
}
finally {
clearVerificationErrors();
}
}
}
- build.xml
refid="classpath_jars"/>
destdir="${test.build.dir}"
includes="*.java"
srcdir="${test.src}"
target="1.5"
classpath="${test.classpath}"
>
ant will execute the full test suite
dest="result.txt" ignoreerrors="true" />
- testing.xml
- config.properties
#BROWSER_TYPE= iexplore
#BROWSER_TYPE= chrome
#BROWSER_TYPE= firefox
APP_URL = http://localhost:8080/
APP_USER_NAME = weblogic
APP_USER_PASSWD = weblogic
BROWSER_TYPE= chrome
28 comments:
Hi,
I am new to testNG and need to develop a framework using Selnium RC and testNG as posted in your blog.Could you please update build.xml and testing.xml files on the posting. It would be a great help!!
Thanks,
Chetas
Hi,
IN linux when i am starting selenium server its not opening the browser.This is showing that my firefox dir is not defined.At which place we have to give that path.
I solved that problem.now browser is opening.everything is working fine.
Hi
ijust started using selenium.
can you pls send me the framework to my emailid d.pradeep1978@gmail.com or give me the link to download
Thanks,
pradeep
In this site I can't upload the Seleniumtestframework.zip file, please let me know where Can i upload this .zip file. So many people are asking for the zip file.
Hi Ravisha,
This is of great help to me. Can you also please share the zip file on my id: shikhar.srivastava07@gmail.com.
Thanks.
Hi Ravisha,
Can you please mail the SeleniumTestFramework.zip to vinay.it@gmail.com
hi ravi
can you please send Seleniumtestframework.zip to s.for.siva@gmail.com
Hi Ravisha,
Could you please post the entire build.xml file ?
Hi,
Can you send the framework zip file to my email id kashok77@gmail.com.
Thanks
Ashok
Hi
i am new to selenium.
can you pls send me the framework to my emailid manojcs1790@gmail.com
Hi Ravisha,
can u send me the entire framework @
harsh.gaurav@gmail.com
Thanks
Hi Ravisha,
Can u send me a sample Data Driven, Keyword Diven and Hybrid Driven Framework(For Mercury Flight Application
http://newtours.demoaut.com/ or www.quikr.com web Application)using Selenium to my
Reading Data and Keywords from Excel Sheet
to my Email: saidhinesh1979@gmail.com
Millions of Thanks in Advance.
Hi Ravisha,
Can u send me a sample Data Driven, Keyword Diven and Hybrid Driven Framework(For Mercury Flight Application
http://newtours.demoaut.com/ or www.quikr.com web Application)using Selenium to my
Reading Data and Keywords from Excel Sheet
to my Email: saidhinesh1979@gmail.com
Millions of Thanks in Advance.
Can u pls send me entire framework @ yanich@gmail.com. thanks in advance
Hi Ravisha,
Can u send me a sample Data Driven, Keyword Driven and Hybrid Driven Framework using Selenium to my mail id yanich@gmail.com
Thanks in advance
Thanks for your post; selenium is most trusted automation tool to validate web application and browser. This tool provides precise and complete information about a software application or environment.
Selenium Training in Chennai
Can you please send me the framework zip file at afshan.mathur@gmail.com
Very useful article... Thanks for sharing your valuable information.... as a beginner it is more informative and useful to me... keep rocks....
Software Testing Training in chennai
It was worth visiting your blog and I have bookmarked your blog. Hope to visit again
click here
Selenium Training in Bangalore|
Selenium Training in Chennai
I am definitely enjoying your website. You definitely have some great insight and great stories.
Java training in Chennai | Java training in Omr
Oracle training in Chennai
Java training in Chennai | Java training in Annanagar
Java training in Chennai | Java training institute in Chennai | Java course in Chennai
Resources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful
python course institute in bangalore
python Course in bangalore
python training institute in bangalore
Well somehow I got to read lots of articles on your blog. It’s amazing how interesting it is for me to visit you very often.
Data Science course in kalyan nagar | Data Science Course in Bangalore
Data Science course in OMR | Data Science Course in Chennai
Data Science course in chennai | Best Data Science training in chennai
Data science course in velachery | Data Science course in Chennai
Data science course in jaya nagar | Data Science course in Bangalore
Data Science interview questions and answers
I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject
rpa training in chennai |rpa course in chennai|
rpa training in bangalore | best rpa training in bangalore | rpa course in bangalore | rpa training institute in bangalore | rpa training in bangalore | rpa online training
Thanks for sharing.
apple service center chennai | apple service center chennai | apple service center chennai | apple service center chennai
I think you have a long story to share and i am glad after long time finally you cam and shared your experience.
Python Online training
python Training in Chennai
Python training in Bangalore
Thank you for allowing me to read it, welcome to the next in a recent article. And thanks for sharing the nice article, keep posting or updating news article.
Data Science course in kalyan nagar
Data Science course in OMR
Data Science course in chennai
Data science course in velachery
Data science course in jaya nagar
Data Science interview questions and answers
Data science course in bangalore
Informative post indeed, I’ve being in and out reading posts regularly and I see alot of engaging people sharing things and majority of the shared information is very valuable and so, here’s my fine read.keep sharing!!!
Android Training in Chennai
Android Online Training in Chennai
Android Training in Bangalore
Android Training in Hyderabad
Android Training in Coimbatore
Android Training
Android Online Training
Post a Comment