JC Web Concepts

Selenium Automation With TestNG

I wanted to start off with a simple tutorial that shows you how to write some simple automation scripts. Basically you write Selenium scripts that will test/verify information on a webpage. Example would be lets say you have a webstore that has a shopping cart. You might want to write automation that goes thru purchasing something to make sure it is working. So here is the video and below that I will have the script as well.

package com.jcwebconcepts.tutorials.basics;

import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class SimpleBrowserTests {
    private String appURL = "http://www.jcwebconcepts.net";

    @Test public void openMyBlog() {
        FirefoxDriver driver = new FirefoxDriver();
        driver.get(appURL);
    }

    @Test public void searchGoogle() {
        FirefoxDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
        driver.findElementByName("q").sendKeys("Apple");
        driver.findElementByName("btnG").click();
    }
}

Setting Up Eclipse

I wanted to talk about how to setup your Eclipse IDE to work with Selenium, Maven, and TestNG. For those who do not know what those are you can click on the link to learn more. I will be making some more posts/tutorials on how to use these items. Eclipse can run on Mac, Linux, and or Windows. You need to have Java installed and if you want to work with SVN then you need the command line SVN client. From the video below here is the list of the sites that you will need to add to Eclipse:


    
    
    
    
        org.apache.maven.plugins
        maven-surefire-plugin
        2.4.3
        
          
              
                  app.env
                  ${app.env}
              
          
        
            **/TestUtilities.java
        
        
    
    
        org.apache.maven.plugins
        maven-compiler-plugin
        
          1.5
          1.5
        
    
      
          org.apache.maven.plugins
          maven-checkstyle-plugin
          2.2
          
              checkstyle.xml
              true
              true
              true
              true
          
          
              
                  validate
                  
                      check
                  
              
          
      
    
    
    
    
    net.sf.jacob-project
    jacob
    1.14.3
    
    
      org.springframework
      spring
      2.5.5
    
    
      org.springframework
      spring-webmvc
      2.5.5
    
    
      org.springframework
      spring-test
      2.5.3
    
    
      javax.servlet.jsp
      jsp-api
      2.1
    
    
      log4j
      log4j
      1.2.14
      runtime
    
    
      javax.servlet
      servlet-api
      2.4
    
    
      oracle
      oracle
      14
      test
    
    
    org.testng
    testng
    5.11
    jdk15
    test
    
    
    org.seleniumhq.selenium
    selenium
    2.0a2
    
    
    org.seleniumhq.selenium
    selenium-server
    2.0a2