Wednesday Feb 10, 2010

Using Selenium TestNG/JUnit and XPath Checker to Automate GlassFish v3 AdminGUI Server

It's been almost 2 years since I first use Selenium/TestNG to automate test cases for SocialSite Project. At that time, I'm not aware of using XPath checker or DOM inspector to identify a web element locator ID.

The Selenium APIs and TestNG harness are much more improving and robust now. Writers should be able to search for any answers from the web since more testers/developers are writing Selenium. My long time headache problem which to open a single browser for running with multiple classes is resolved in TestNG interface ITestContext - put it before and after you start/stop your test class

public void startBrowser(ITestContext context){
        browser = new DefaultSelenium();
        context.setAttribute("browser",browser);
        browser.start(); }

public void stopBrowser(ITestContext context) {
       browser = (DefaultSelenium) context.getAttribute("browser",browser);
       browser.stop(); }

I'm writing test for both JUnit and testNG frameworks.  JUnit harness has been widely using in developers community so if one doesn't often share the workspace with developers, I suggest using TestNG frameworks

TestNG has more annotations which provides more flexibility, less test depedency, advanced parametric and re-runable features. In addition, TestNG result is automatically reported in xml/html format.

Click here for my GlassFish V3 Acceptance Test Model

My preferences to the xpath links http://seleniumhq.org/docs/04_selenese_commands.html
http://www.mulberrytech.com/quickref/ http://blogs.sun.com/rajeshthekkadath/entry/xpath_identifying_xpath_of_a

Tuesday Feb 19, 2008

Record a Simple Glassfish Test Case with Selenium


This screencast shows you steps to record a simple glassfish deployment test case with selenium.

After click Play, please wait for the screencast to load

Monday Feb 11, 2008

Glassfish GUI Automation with Selenium (Java)

Want to try Glassfish Admin GUI with Selenium and experience the differences between SilkTest and Selenium tools


1. Run Selenium from the build 
If you build admin-gui module you can find the README.SeleniumRC file under the ../glassfish/admin-gui/tests directory. Just follow the instruction from the file, you should be able to setup and run Selenium JBI tests with Glassfish Admin GUI. If you encounter a failure from your browser, open selenium test case files under java directory and replace statement
selenium.waitForCondition("Selenium.browserbot.isNewPageLoaded()", TIMEOUT_PERIOD) by
selenium.waitForPageToLoad( TIMEOUT_PERIOD)


2. Run Selenium with Glassfish V2 binary bit
    1. You must setup the environment by installing Selenium IDE on your Firefox browser
    2. Having ant 1.6.5 and jdk1.5.0_11 or latest version installed on your system
    3. Create a AdminGUITest directory on your system and copy the following 4 files to the ../AdminGUITest/lib directory
selenium-server.jar , selenium-java-client.jar, selenium-java-client-driver-tests.jar and testng-5.5-jdk15.jar  and junit.jar
     4. Copy the simple test harness (AdminGUITest.jar file) to your AdminGUI directory and unjar the file
     5. Update build.properties file  with your setup environment
     6. Start the selenium remote server (assume you're using a window system)
cd  %AdminGUITest.home%
             java -jar selenium-server.jar
     7. Start glassfish domain1
     8. Run the first AdminGUI test case
             cd  %AdminGUITest.home%
      ant run-test
3. Differences between SilkTest and Selenium




































































































Features Selenium SilkTest
HTLM Web Object Support Yes Yes
Easy Creation Object Scripts (Record and Playback) Yes
Yes
Scripting in variety languages (Java, Perl, C#, PHP, ..) Yes No (Only 4test language)
Ability to run test with build scripts (maven, ant,..) Yes No
Support Different Browsers Yes Yes
Reusability of Scripts Yes Yes
Commercial Support Yes Yes
Test Debugging Yes Yes
Result Reporting Fair Yes
Exception Handling Fair Yes
Java Objects (beyond the browsers) No Yes
Https protocol support Yes (some configuration required)
Yes
Capable of record exactly same as end-user desire Fair Yes
Organize tests according to the manual Test Plan No Yes
Data Driven Test Framework No Yes
Mechanism to create test independently (one test should not depend on other) No
Yes
Support Multiple OS Yes Yes
Comprehesive Test (run for > 8 hrs)
Weak Yes

About

davisn

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today