SlideShare a Scribd company logo
1 of 8
1. What are the pre-requisites to run Selenium RC tests with
    Junit?
Wed, 05/04/2011 - 08:30 — Srinivasa Bittla
The pre-requisites to run Selenium RC tests with Junit:
1) Jre 1.5 or better version needs to be installed
2) /jre/bin folder must be added in environment variable "path"
3) Junit folder path must be added to path or build path in eclipse
4) Selenium Java Client drivers needs to be added to the path for execution


2. How to configure Selenium RC with eclipse to run Junit
    Tests?
Wed, 05/04/2011 - 08:31 — Srinivasa Bittla
1) Download eclipse. click here to download the software
2) Open eclipse -> Workspace Launcher window will open
3) Create a workspace by giving meaningful name
3) Click on Workbench
4) Create a project of type java
5) Create a package under src folder of the package
6) Add Junit to the build path
7) Add selenium rc java client driver to the build path
8) Now drag and drop your test script (.which is exported from Selenium IDE) to the package
created


3. Which is the command used for running the Selenium RC
    Server?
Wed, 05/04/2011 - 08:33 — Srinivasa Bittla
The procedure followed to run the Selenium RC Server is:
1. Open the command prompt.
2. Change the folder path to Selenium RC Server
3. Issue the command "java -jar selenium-server.jar"
4. For more options on how to start selenium server. Please have a look at Selenium RC Server
startup Options


4. How do you run selenium commands in slow motion in
    Selenium RC?
Wed, 05/04/2011 - 08:34 — Srinivasa Bittla
You can run the selenium commands in RC slow motion by two ways:
selenium.setSpeed
thread.sleep
5. What is the difference between Thread.Sleep() and
    Selenium.setSpeed()?
Wed, 05/04/2011 - 08:35 — Srinivasa Bittla
selenium.setSpeed
1. takes a single argument in string format
ex: selenium.setSpeed("2000") - will wait for 2 seconds
2. Runs each command in after setSpeed delay by the number of milliseconds mentioned in
setSpeed.
thread.sleep
1. takes a single argument in integer format
ex: thread.sleep(2000) - will wait for 2 seconds
2. Waits for only once at the command given at sleep.


6. Why do you use assert and verify statements in Selenium
    RC without referring to selenium?
Wed, 05/04/2011 - 08:36 — Srinivasa Bittla
SeleneseTestCase is the class which is having
1. assertTrue
2. verifyTrue
3. assertEquals
4. verifyEquals
We use SeleneseTestCase class to extend the selenium test class file.
For Ex: the test class is declared as follows
public class BookFlightSel1 extends SeleneseTestCase
In the above example SeleneseTestCase is the base class and BookFlightSel1 is the derived class.
So, we can directly call and use the parent class methods verify and assert without instantiating the
class in BookFlightSel1 class.


7. Which are the annotations generated with JUnit 4 tests in
    Selenium IDE?
Wed, 05/04/2011 - 08:37 — Srinivasa Bittla
The annotations generated with JUnit 4 tests in Selenium are:
1. @Before public void method() - Will perform the method() before each test. This method can
prepare the test
2. @Test public void method() - Annotation @Test identifies that this method is a test
method.environment, e.g. read input data, initialize the class)
3. @After public void method() - Annotation @After is executed after the test is been executed and
this method consists of post test operations such as closure of the application.


8. What are the challenges with Selenium RC test suites when
    running in JUnit?
Wed, 05/04/2011 - 08:38 — Srinivasa Bittla
The challenges with Selenium RC test suites when running in JUnit
1. Each test case of Selenium RC test will invoke the browser and closes after playing back
2. All the Test cases cannot run on a single browser session
3. If there is any dependency between the test cases, it is very difficult to execute
4. Running the test suites in junit will be helpful for only independent test cases.
Note: The dependent test case related issues can be addressed by using TestNG with junit


9. What are the advantages of using TestNG over Junit?
Wed, 05/04/2011 - 08:39 — Srinivasa Bittla
The advantages of using TestNG over Junit:
1. The challenges of junit can be addressed using TestNG read What are the challenges with
Selenium RC test suites when running in JUnit? for more details
2. You can execute the test cases dependent with each other read Runnning Selenium RC Tests
Sequentially using TestNG for more details
3. You can execute test cases in a group read Use Group in TestNG framework for more details
4. You can generate the reports using TestNg


10. What are the basic annotations used to run TestNG tests in
    Selenium?
Wed, 05/04/2011 - 23:17 — Srinivasa Bittla
The basic annotations used to run TestNG tests in Selenium RC:
1. @BeforeClass: The annotated method with @BeforeClass will be run before the first test method
in the current class is invoked.
2. @AfterClass: The annotated method with @AfterClass will be run after all the test methods in
the current class have been run.
3. @BeforeMethod: The annotated method with @BeforeMethod will be run before each test
method.
4. @AfterMethod: The annotated method with @AfterMethod will be run after each test method.
5. @Test: Marks a class or a method @Test with as part of the test.


11. How to run test cases with dependent in Selenium using
    TestNG?
Wed, 05/04/2011 - 23:29 — Srinivasa Bittla
The @Test should be followed by (dependsOnMethods = "testLogin")
Note:- The test case will be executed after the testLogin case
Ex: @Test(dependsOnMethods = "testLogin")


12. How to run the test cases in group in Selenium using
    TestNG?
Wed, 05/04/2011 - 23:30 — Srinivasa Bittla
Test cases in group in Selenium using TestNG will be executed with the below options.
If you want to execute the test cases based on one of the group like regressiontest or smoketest
@Test(groups = {"regressiontest", "smoketest"})


13. How to execute the test cases in an XML format using
    TestNG in Selenium?
Wed, 05/04/2011 - 23:32 — Srinivasa Bittla
If you want to execute a java file MercTestNgSuite.java which is there in the package
com.src.testng. You can use the below mentioned code in a xml file. And the test can be run by right
clicking the XML and running as TestNG Suite
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="5" skipfailedinvocationCounts="false" verbose="1" name="MercPrj"
junit="false" parallel="false" annotations="JDK">
<test verbose="2" name="com.src.testng.MercTestNgSuite" junit="false" annotations="JDK">
<classes>
<class name="com.src.testng.MercTestNgSuite"/>
</classes>
</test>
</suite> ??


14. How to incude or exclude the selenium rc test cases using
    xml in TestNG?
Wed, 05/04/2011 - 23:33 — Srinivasa Bittla
Including or excluding of selenium rc test cases using xml in TestNG can be done using the
keywords include or exlude
For including a test case we need to use <include name="method name"/> under the class
whichever the method you want to include
For excluding a test case we need to use <exclude name="method name"/> under the class
whichever the method you want to include
For example if you have a class MercTestNgSuite in package com.src.testng want to include the
methods like:
1. testLogin1
2. testFindFlights
3. testSelectFlights
4. testFillUserDetails
5. testVerifyFlightConf
and exclude
6. testLogout
the xml can be written as mentioned below.
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="5" skipfailedinvocationCounts="false" verbose="1" name="MercPrj"
junit="false" parallel="false" annotations="JDK">
<test verbose="2" name="com.src.testng.MercTestNgSuite" junit="false" annotations="JDK">
<classes>
<class name="com.src.testng.MercTestNgSuite"/>
<methods>
<include name="testLogin1"/>
<include name="testFindFlights"/>
<include name="testSelectFlights"/>
<include name="testFillUserDetails"/>
<include name="testVerifyFlightConf"/>
<exclude name="testLogout"/>
</methods>
</classes>
</test>


15. How to execute the selenium test suite with testNG in
    XML?
Wed, 05/04/2011 - 23:33 — Srinivasa Bittla
Assume that you have two classes which are having suite of test cases with the below mentioned
methods.
class1 or suite 1: the class by name MercTestNgSuite in the package com.src.testng with the
methods
1. testLogin1
2. testFindFlights
3. testSelectFlights
4. testFillUserDetails
class1 or suite 2:the class by name MercTestNgSuite2 in the package com.src.testng with the
methods
1. testLogin1
2. testFindFlights
3. testSelectFlights
4. testFillUserDetails
5. testVerifyFlightConf
6. testLogout
The two class suites can be executed as mentioned
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="5" skipfailedinvocationCounts="false" verbose="1" name="MercPrj"
junit="false" parallel="false" annotations="JDK">
<test verbose="2" name="com.src.testng.*" junit="false" annotations="JDK">
<classes>
<class name="com.src.testng.MercTestNgSuite"/>
<methods>
<include name="testLogin1"/>
<include name="testFindFlights"/>
<include name="testSelectFlights"/>
<include name="testFillUserDetails"/>
</methods>
<class name="com.src.testng.MercTestNgSuite2"/>
<methods>
<include name="testLogin1"/>
<include name="testFindFlights"/>
<include name="testSelectFlights"/>
<include name="testFillUserDetails"/>
<include name="testVerifyFlightConf"/>
<include name="testLogout"/>
</methods>
</classes>
</test>
</suite>


16. How to run Selenium IDE test suite with user extensions
    using Selenium Remote Control?
Fri, 05/06/2011 - 22:59 — Srinivasa Bittla
Read this forum topic for How to run Selenium IDE TestSuite with Selenium Remote Control
to run Selenium IDE test suite with user extensions using Selenium Remote Control we need to use
the below command.
java -jar selenium-server.jar -userExtensions user-extensions.js -htmlSuite "*<browser>" "<base
URL>" "<Selenium test suite file>" "<results log file>" -timeout <millise>



17. How to start selenium rc server with user extensions?
Wed, 05/11/2011 - 11:42 — Srinivasa Bittla
The command used is
java -jar selenium-server.jar -userExtensions user-extensions.js
Note: In this case, the java script file user-extensions.js file name should always fixed. If the name
or extension is changed the selenium rc server will not start.


18. What are the limitations of selenium RC
Fri, 07/15/2011 - 23:14 — Srinivasa Bittla
The limitations of selenium RC are:
1) Switching between the multiple instances of the same browser is not possible
2) Switching between the multiple instances of the different browsers is not possible
3) Browser navigation, like back and forward button emulations is not possible
4) Limited features in terms of drag and drop of objects
5) To work with Ajax based UI elements there are very limited features are there with Selenium RC
To overcome the above limitations we use selenium web driver or google web driver


19. How to do database testing using selenium rc?
Wed, 09/21/2011 - 22:51 — Srinivasa Bittla
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[] )
{
try{
// LOAD THE DATABASE DRIVER
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ) ;
// ESTABLISH THE CONNECTION TO THE DATABASE
Connection conn = DriverManager.getConnection( "jdbc:odbc:QT_Flight32" ) ;
// GET A STATEMENT FOR THE CONNECTION
Statement stmt = conn.createStatement() ;
// PREPARE THE SQL STATEMENT
String strSQL = "SELECT * FROM Orders";
// EXECUTE THE SQL QUERY AND STORE IN RESULTS SET
ResultSet rs = stmt.executeQuery( strSQL ) ;
// LOOP THE RESULT TILL IT REACHED END
// rs.getString(1) - FIRST COLUMN
// rs.getString(2) - SECOND COLUMN ETC
while( rs.next() )
System.out.println( rs.getString(1) + rs.getString(2)+ rs.getString(3)+ rs.getString(4)) ;
// CLOSE THE RESULT, STATEMENT AND CONNECTION
rs.close() ;
stmt.close() ;
conn.close() ;
}
// HANDLE THE SQL EXCEPTION
catch( SQLException se ) {
System.out.println( "SQL Exception:" ) ;
// PRINT TILL ALL THE ECEPTIONS ARE RAISED
while( se != null ) {
System.out.println( "State : " + se.getSQLState() ) ;
System.out.println( "Message: " + se.getMessage() ) ;
System.out.println( "Error : " + se.getErrorCode() ) ;
se = se.getNextException() ;
}
}
//CATCH THE CLASS EXCEPTION
catch( Exception e ) {
System.out.println( e ) ;
}
}
}

More Related Content

What's hot

TestNG Session presented in PB
TestNG Session presented in PBTestNG Session presented in PB
TestNG Session presented in PBAbhishek Yadav
 
TestNG Session presented in Xebia XKE
TestNG Session presented in Xebia XKETestNG Session presented in Xebia XKE
TestNG Session presented in Xebia XKEAbhishek Yadav
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ideTestertester Jaipur
 
TestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warTestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warOleksiy Rezchykov
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introductionDenis Bazhin
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockitoshaunthomas999
 
TestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit TestingTestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit TestingBethmi Gunasekara
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentationSanjib Dhar
 
JUnit 5 - The Next Generation
JUnit 5 - The Next GenerationJUnit 5 - The Next Generation
JUnit 5 - The Next GenerationKostadin Golev
 
Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Gopi Raghavendra
 

What's hot (20)

TestNG Session presented in PB
TestNG Session presented in PBTestNG Session presented in PB
TestNG Session presented in PB
 
TestNG Session presented in Xebia XKE
TestNG Session presented in Xebia XKETestNG Session presented in Xebia XKE
TestNG Session presented in Xebia XKE
 
Selenium TestNG
Selenium TestNGSelenium TestNG
Selenium TestNG
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ide
 
TestNG
TestNGTestNG
TestNG
 
TestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warTestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the war
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
 
Test ng
Test ngTest ng
Test ng
 
Selenium with java
Selenium with javaSelenium with java
Selenium with java
 
TestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit TestingTestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit Testing
 
TestNG vs. JUnit4
TestNG vs. JUnit4TestNG vs. JUnit4
TestNG vs. JUnit4
 
TDD - Unit Testing
TDD - Unit TestingTDD - Unit Testing
TDD - Unit Testing
 
testng
testngtestng
testng
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentation
 
JUnit 5 - The Next Generation
JUnit 5 - The Next GenerationJUnit 5 - The Next Generation
JUnit 5 - The Next Generation
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)
 
TestNG Data Binding
TestNG Data BindingTestNG Data Binding
TestNG Data Binding
 
Test ng
Test ngTest ng
Test ng
 

Viewers also liked

Let's Talk About Social Networking
Let's Talk About Social NetworkingLet's Talk About Social Networking
Let's Talk About Social NetworkingSteve Lowisz
 
Top 8 regulatory affairs officer resume samples
Top 8 regulatory affairs officer resume samplesTop 8 regulatory affairs officer resume samples
Top 8 regulatory affairs officer resume samplestonychoper6205
 
六合彩,香港六合彩 » SlideShare
六合彩,香港六合彩 » SlideShare六合彩,香港六合彩 » SlideShare
六合彩,香港六合彩 » SlideShareaxluwjc
 
Recruit.... or get out of the way!
Recruit.... or get out of the way!Recruit.... or get out of the way!
Recruit.... or get out of the way!Steve Lowisz
 
Jmeter interviewquestions
Jmeter interviewquestionsJmeter interviewquestions
Jmeter interviewquestionsgirichinna27
 
The Motivation Myth
The Motivation MythThe Motivation Myth
The Motivation MythSteve Lowisz
 
quality of hire mishrm oct 2014 steve lowisz
quality of hire mishrm oct 2014 steve lowiszquality of hire mishrm oct 2014 steve lowisz
quality of hire mishrm oct 2014 steve lowiszSteve Lowisz
 
Qualigence Vs Competitors
Qualigence Vs CompetitorsQualigence Vs Competitors
Qualigence Vs CompetitorsSteve Lowisz
 
Mapsofczech
MapsofczechMapsofczech
Mapsofczechhalbert
 
Selenium interview questions
Selenium interview questionsSelenium interview questions
Selenium interview questionsgirichinna27
 

Viewers also liked (10)

Let's Talk About Social Networking
Let's Talk About Social NetworkingLet's Talk About Social Networking
Let's Talk About Social Networking
 
Top 8 regulatory affairs officer resume samples
Top 8 regulatory affairs officer resume samplesTop 8 regulatory affairs officer resume samples
Top 8 regulatory affairs officer resume samples
 
六合彩,香港六合彩 » SlideShare
六合彩,香港六合彩 » SlideShare六合彩,香港六合彩 » SlideShare
六合彩,香港六合彩 » SlideShare
 
Recruit.... or get out of the way!
Recruit.... or get out of the way!Recruit.... or get out of the way!
Recruit.... or get out of the way!
 
Jmeter interviewquestions
Jmeter interviewquestionsJmeter interviewquestions
Jmeter interviewquestions
 
The Motivation Myth
The Motivation MythThe Motivation Myth
The Motivation Myth
 
quality of hire mishrm oct 2014 steve lowisz
quality of hire mishrm oct 2014 steve lowiszquality of hire mishrm oct 2014 steve lowisz
quality of hire mishrm oct 2014 steve lowisz
 
Qualigence Vs Competitors
Qualigence Vs CompetitorsQualigence Vs Competitors
Qualigence Vs Competitors
 
Mapsofczech
MapsofczechMapsofczech
Mapsofczech
 
Selenium interview questions
Selenium interview questionsSelenium interview questions
Selenium interview questions
 

Similar to Selenium RC Tests with JUnit and TestNG

Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersAjit Jadhav
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
Hybrid automation framework
Hybrid automation frameworkHybrid automation framework
Hybrid automation frameworkdoai tran
 
Seleniuminterviewquestions
Seleniuminterviewquestions Seleniuminterviewquestions
Seleniuminterviewquestions laxmiraj01
 
Dev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetDev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetdevlabsalliance
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance
 
Dev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDETDev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDETdevlabsalliance
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance
 
Developing Selenium tests with JUnit 5
Developing Selenium tests with JUnit 5Developing Selenium tests with JUnit 5
Developing Selenium tests with JUnit 5Boni García
 
First steps with selenium rc
First steps with selenium rcFirst steps with selenium rc
First steps with selenium rcDang Nguyen
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshopcoreyjack
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributorsmichael.labriola
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshersNaga Mani
 
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"Agile Testing Alliance
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With SeleniumJodie Miners
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Puneet Kala
 

Similar to Selenium RC Tests with JUnit and TestNG (20)

Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
Hybrid automation framework
Hybrid automation frameworkHybrid automation framework
Hybrid automation framework
 
Seleniuminterviewquestions
Seleniuminterviewquestions Seleniuminterviewquestions
Seleniuminterviewquestions
 
Dev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetDev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdet
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
 
Dev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDETDev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDET
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
 
Developing Selenium tests with JUnit 5
Developing Selenium tests with JUnit 5Developing Selenium tests with JUnit 5
Developing Selenium tests with JUnit 5
 
First steps with selenium rc
First steps with selenium rcFirst steps with selenium rc
First steps with selenium rc
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshop
 
Selenium training in chennai
Selenium training in chennaiSelenium training in chennai
Selenium training in chennai
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributors
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
 
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With Selenium
 
Selenium Primer
Selenium PrimerSelenium Primer
Selenium Primer
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
Selenium online training
Selenium online trainingSelenium online training
Selenium online training
 
jDriver Presentation
jDriver PresentationjDriver Presentation
jDriver Presentation
 

Selenium RC Tests with JUnit and TestNG

  • 1. 1. What are the pre-requisites to run Selenium RC tests with Junit? Wed, 05/04/2011 - 08:30 — Srinivasa Bittla The pre-requisites to run Selenium RC tests with Junit: 1) Jre 1.5 or better version needs to be installed 2) /jre/bin folder must be added in environment variable "path" 3) Junit folder path must be added to path or build path in eclipse 4) Selenium Java Client drivers needs to be added to the path for execution 2. How to configure Selenium RC with eclipse to run Junit Tests? Wed, 05/04/2011 - 08:31 — Srinivasa Bittla 1) Download eclipse. click here to download the software 2) Open eclipse -> Workspace Launcher window will open 3) Create a workspace by giving meaningful name 3) Click on Workbench 4) Create a project of type java 5) Create a package under src folder of the package 6) Add Junit to the build path 7) Add selenium rc java client driver to the build path 8) Now drag and drop your test script (.which is exported from Selenium IDE) to the package created 3. Which is the command used for running the Selenium RC Server? Wed, 05/04/2011 - 08:33 — Srinivasa Bittla The procedure followed to run the Selenium RC Server is: 1. Open the command prompt. 2. Change the folder path to Selenium RC Server 3. Issue the command "java -jar selenium-server.jar" 4. For more options on how to start selenium server. Please have a look at Selenium RC Server startup Options 4. How do you run selenium commands in slow motion in Selenium RC? Wed, 05/04/2011 - 08:34 — Srinivasa Bittla You can run the selenium commands in RC slow motion by two ways: selenium.setSpeed thread.sleep
  • 2. 5. What is the difference between Thread.Sleep() and Selenium.setSpeed()? Wed, 05/04/2011 - 08:35 — Srinivasa Bittla selenium.setSpeed 1. takes a single argument in string format ex: selenium.setSpeed("2000") - will wait for 2 seconds 2. Runs each command in after setSpeed delay by the number of milliseconds mentioned in setSpeed. thread.sleep 1. takes a single argument in integer format ex: thread.sleep(2000) - will wait for 2 seconds 2. Waits for only once at the command given at sleep. 6. Why do you use assert and verify statements in Selenium RC without referring to selenium? Wed, 05/04/2011 - 08:36 — Srinivasa Bittla SeleneseTestCase is the class which is having 1. assertTrue 2. verifyTrue 3. assertEquals 4. verifyEquals We use SeleneseTestCase class to extend the selenium test class file. For Ex: the test class is declared as follows public class BookFlightSel1 extends SeleneseTestCase In the above example SeleneseTestCase is the base class and BookFlightSel1 is the derived class. So, we can directly call and use the parent class methods verify and assert without instantiating the class in BookFlightSel1 class. 7. Which are the annotations generated with JUnit 4 tests in Selenium IDE? Wed, 05/04/2011 - 08:37 — Srinivasa Bittla The annotations generated with JUnit 4 tests in Selenium are: 1. @Before public void method() - Will perform the method() before each test. This method can prepare the test 2. @Test public void method() - Annotation @Test identifies that this method is a test method.environment, e.g. read input data, initialize the class) 3. @After public void method() - Annotation @After is executed after the test is been executed and this method consists of post test operations such as closure of the application. 8. What are the challenges with Selenium RC test suites when running in JUnit? Wed, 05/04/2011 - 08:38 — Srinivasa Bittla
  • 3. The challenges with Selenium RC test suites when running in JUnit 1. Each test case of Selenium RC test will invoke the browser and closes after playing back 2. All the Test cases cannot run on a single browser session 3. If there is any dependency between the test cases, it is very difficult to execute 4. Running the test suites in junit will be helpful for only independent test cases. Note: The dependent test case related issues can be addressed by using TestNG with junit 9. What are the advantages of using TestNG over Junit? Wed, 05/04/2011 - 08:39 — Srinivasa Bittla The advantages of using TestNG over Junit: 1. The challenges of junit can be addressed using TestNG read What are the challenges with Selenium RC test suites when running in JUnit? for more details 2. You can execute the test cases dependent with each other read Runnning Selenium RC Tests Sequentially using TestNG for more details 3. You can execute test cases in a group read Use Group in TestNG framework for more details 4. You can generate the reports using TestNg 10. What are the basic annotations used to run TestNG tests in Selenium? Wed, 05/04/2011 - 23:17 — Srinivasa Bittla The basic annotations used to run TestNG tests in Selenium RC: 1. @BeforeClass: The annotated method with @BeforeClass will be run before the first test method in the current class is invoked. 2. @AfterClass: The annotated method with @AfterClass will be run after all the test methods in the current class have been run. 3. @BeforeMethod: The annotated method with @BeforeMethod will be run before each test method. 4. @AfterMethod: The annotated method with @AfterMethod will be run after each test method. 5. @Test: Marks a class or a method @Test with as part of the test. 11. How to run test cases with dependent in Selenium using TestNG? Wed, 05/04/2011 - 23:29 — Srinivasa Bittla The @Test should be followed by (dependsOnMethods = "testLogin") Note:- The test case will be executed after the testLogin case Ex: @Test(dependsOnMethods = "testLogin") 12. How to run the test cases in group in Selenium using TestNG? Wed, 05/04/2011 - 23:30 — Srinivasa Bittla Test cases in group in Selenium using TestNG will be executed with the below options. If you want to execute the test cases based on one of the group like regressiontest or smoketest
  • 4. @Test(groups = {"regressiontest", "smoketest"}) 13. How to execute the test cases in an XML format using TestNG in Selenium? Wed, 05/04/2011 - 23:32 — Srinivasa Bittla If you want to execute a java file MercTestNgSuite.java which is there in the package com.src.testng. You can use the below mentioned code in a xml file. And the test can be run by right clicking the XML and running as TestNG Suite <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite thread-count="5" skipfailedinvocationCounts="false" verbose="1" name="MercPrj" junit="false" parallel="false" annotations="JDK"> <test verbose="2" name="com.src.testng.MercTestNgSuite" junit="false" annotations="JDK"> <classes> <class name="com.src.testng.MercTestNgSuite"/> </classes> </test> </suite> ?? 14. How to incude or exclude the selenium rc test cases using xml in TestNG? Wed, 05/04/2011 - 23:33 — Srinivasa Bittla Including or excluding of selenium rc test cases using xml in TestNG can be done using the keywords include or exlude For including a test case we need to use <include name="method name"/> under the class whichever the method you want to include For excluding a test case we need to use <exclude name="method name"/> under the class whichever the method you want to include For example if you have a class MercTestNgSuite in package com.src.testng want to include the methods like: 1. testLogin1 2. testFindFlights 3. testSelectFlights 4. testFillUserDetails 5. testVerifyFlightConf and exclude 6. testLogout the xml can be written as mentioned below. <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite thread-count="5" skipfailedinvocationCounts="false" verbose="1" name="MercPrj" junit="false" parallel="false" annotations="JDK"> <test verbose="2" name="com.src.testng.MercTestNgSuite" junit="false" annotations="JDK"> <classes> <class name="com.src.testng.MercTestNgSuite"/>
  • 5. <methods> <include name="testLogin1"/> <include name="testFindFlights"/> <include name="testSelectFlights"/> <include name="testFillUserDetails"/> <include name="testVerifyFlightConf"/> <exclude name="testLogout"/> </methods> </classes> </test> 15. How to execute the selenium test suite with testNG in XML? Wed, 05/04/2011 - 23:33 — Srinivasa Bittla Assume that you have two classes which are having suite of test cases with the below mentioned methods. class1 or suite 1: the class by name MercTestNgSuite in the package com.src.testng with the methods 1. testLogin1 2. testFindFlights 3. testSelectFlights 4. testFillUserDetails class1 or suite 2:the class by name MercTestNgSuite2 in the package com.src.testng with the methods 1. testLogin1 2. testFindFlights 3. testSelectFlights 4. testFillUserDetails 5. testVerifyFlightConf 6. testLogout The two class suites can be executed as mentioned <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite thread-count="5" skipfailedinvocationCounts="false" verbose="1" name="MercPrj" junit="false" parallel="false" annotations="JDK"> <test verbose="2" name="com.src.testng.*" junit="false" annotations="JDK"> <classes> <class name="com.src.testng.MercTestNgSuite"/> <methods> <include name="testLogin1"/> <include name="testFindFlights"/> <include name="testSelectFlights"/> <include name="testFillUserDetails"/> </methods> <class name="com.src.testng.MercTestNgSuite2"/> <methods>
  • 6. <include name="testLogin1"/> <include name="testFindFlights"/> <include name="testSelectFlights"/> <include name="testFillUserDetails"/> <include name="testVerifyFlightConf"/> <include name="testLogout"/> </methods> </classes> </test> </suite> 16. How to run Selenium IDE test suite with user extensions using Selenium Remote Control? Fri, 05/06/2011 - 22:59 — Srinivasa Bittla Read this forum topic for How to run Selenium IDE TestSuite with Selenium Remote Control to run Selenium IDE test suite with user extensions using Selenium Remote Control we need to use the below command. java -jar selenium-server.jar -userExtensions user-extensions.js -htmlSuite "*<browser>" "<base URL>" "<Selenium test suite file>" "<results log file>" -timeout <millise> 17. How to start selenium rc server with user extensions? Wed, 05/11/2011 - 11:42 — Srinivasa Bittla The command used is java -jar selenium-server.jar -userExtensions user-extensions.js Note: In this case, the java script file user-extensions.js file name should always fixed. If the name or extension is changed the selenium rc server will not start. 18. What are the limitations of selenium RC Fri, 07/15/2011 - 23:14 — Srinivasa Bittla The limitations of selenium RC are: 1) Switching between the multiple instances of the same browser is not possible 2) Switching between the multiple instances of the different browsers is not possible 3) Browser navigation, like back and forward button emulations is not possible 4) Limited features in terms of drag and drop of objects 5) To work with Ajax based UI elements there are very limited features are there with Selenium RC To overcome the above limitations we use selenium web driver or google web driver 19. How to do database testing using selenium rc? Wed, 09/21/2011 - 22:51 — Srinivasa Bittla
  • 7. 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[] ) { try{ // LOAD THE DATABASE DRIVER Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ) ; // ESTABLISH THE CONNECTION TO THE DATABASE Connection conn = DriverManager.getConnection( "jdbc:odbc:QT_Flight32" ) ; // GET A STATEMENT FOR THE CONNECTION Statement stmt = conn.createStatement() ; // PREPARE THE SQL STATEMENT String strSQL = "SELECT * FROM Orders"; // EXECUTE THE SQL QUERY AND STORE IN RESULTS SET ResultSet rs = stmt.executeQuery( strSQL ) ; // LOOP THE RESULT TILL IT REACHED END // rs.getString(1) - FIRST COLUMN // rs.getString(2) - SECOND COLUMN ETC while( rs.next() ) System.out.println( rs.getString(1) + rs.getString(2)+ rs.getString(3)+ rs.getString(4)) ; // CLOSE THE RESULT, STATEMENT AND CONNECTION rs.close() ; stmt.close() ; conn.close() ; } // HANDLE THE SQL EXCEPTION catch( SQLException se ) { System.out.println( "SQL Exception:" ) ; // PRINT TILL ALL THE ECEPTIONS ARE RAISED while( se != null ) { System.out.println( "State : " + se.getSQLState() ) ; System.out.println( "Message: " + se.getMessage() ) ;
  • 8. System.out.println( "Error : " + se.getErrorCode() ) ; se = se.getNextException() ; } } //CATCH THE CLASS EXCEPTION catch( Exception e ) { System.out.println( e ) ; } } }