TestLab

  Home / Services
Services
Our Services
Software Testing Process
Functional Testing
Configuration Testing
Performance Testing
Software Testing Tools
Automated Testing
Security Testing
Installation Testing
Regression Testing
Script Examples - Automated QA TestComplete
Script Examples - Selenium

     

Script Examples - Selenium

This script was developed by QATestlab team in order to test web-based  application with the help of Selenium RC.

Sample Script for Selenium RC


import org.testng.annotations.AfterTest;

import org.testng.annotations.BeforeTest;

import org.testng.annotations.Test;

 

import com.thoughtworks.selenium.DefaultSelenium;

import com.thoughtworks.selenium.SeleneseTestCase;


public class WellPrizeSponsorTest extends SeleneseTestCase

{

     

@Test

public void testLogin(){

             

selenium.open(WellSphere.appPath);

selenium.waitForPageToLoad(WellSphere.timeout);

if (selenium.isTextPresent("Log in"))

{

  selenium.click("link=Log in");

  selenium.waitForPageToLoad(WellSphere.timeout);

  selenium.type("email", WellSphere.username);

  selenium.type("password", WellSphere.password);

  selenium.click

  ("//td[1]/table/tbody/tr/td/a/div[1]/div/div/b");

  selenium.waitForPageToLoad(WellSphere.timeout);

  assertTrue(selenium.isTextPresent("My Wellsphere"));

  System.out.println("Log In passed");

  System.out.println("User is logged in successfully");   

 }

}

 

public void testWellPrizeTest() throws Throwable {

  try {

     selenium.click("link=My Wellsphere");

     selenium.waitForPageToLoad(WellSphere.timeout);

     if (selenium.isElementPresent("link=Remove"))

      {

        selenium.click("link=Remove");

        assertTrue(selenium.getConfirmation().matches

        ("^Are you sure you want to delete reward[sS]$"));

        selenium.waitForPageToLoad(WellSphere.timeout);

      }

      assertTrue(selenium.isElementPresent

      ("link=›› Choose a WellPrize"));

      selenium.click("link=›› Choose a WellPrize");

      selenium.waitForPageToLoad(WellSphere.timeout);

    

      if (selenium.isTextPresent("Reward Yourself!"))

  {    {          

            selenium.click

            ("link=Browse our WellPrize Catalog");

            selenium.waitForPageToLoad(WellSphere.timeout);

           

        }

           

selenium.click("link=Beauty");

selenium.waitForPageToLoad(WellSphere.timeout);

selenium.click("link=Choose as WellPrize");

selenium.waitForPageToLoad(WellSphere.timeout);

assertTrue(selenium.isTextPresent

("You have selected the following WellPrize"));

selenium.click("document.

createRewardForm.rewardGetType[1]");

selenium.click("link=Submit");

selenium.waitForPageToLoad(WellSphere.timeout);

assertEquals(selenium.getValue("name=subject"),

"Will you sponsor me to help me stick to my goals?");

selenium.type("contactsString", WellSphere.username);

selenium.click("link=Send");

selenium.waitForPageToLoad(WellSphere.timeout);

assertTrue(selenium.isTextPresent

("Your message has been sent successfully"));

assertTrue(selenium.isElementPresent

("link=Change"));

selenium.click("link=Logout");

selenium.waitForPageToLoad(WellSphere.timeout);

selenium.click("link=Log in");

selenium.waitForPageToLoad(WellSphere.timeout);

selenium.type("email", WellSphere.username2);

selenium.type("password", WellSphere.password2);

selenium.click

("//td[1]/table/tbody/tr/td/a/div[1]/div/div/b");

selenium.waitForPageToLoad(WellSphere.timeout);

assertTrue(selenium.isTextPresent("My Wellsphere"));

selenium.open(WellSphere.appPath

+ "/confirmSponsorship.s?id=15138");

selenium.waitForPageToLoad(WellSphere.timeout);

selenium.click

("//div[7]/div[1]/table/tbody/tr/td/a/div[1]/div/div/b");

selenium.waitForPageToLoad("100000");

selenium.click("link=Send");

selenium.waitForPageToLoad("100000");

selenium.click

("link=‹ Return to previous page");

selenium.waitForPageToLoad("100000");

assertTrue(selenium.isElementPresent

("link=Remove myself as sponsor"));

System.out.println

("Sponsor remove himself Test passed"); 

checkForVerificationErrors();

}

      


 
{rs:MEMBER_HITECH} {rs:UOF_SPONSOR}