Advertisement
Guest User

Selenium script

a guest
Jun 20th, 2012
1,059
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.66 KB | None | 0 0
  1. import com.thoughtworks.selenium.*;
  2.  
  3. import org.junit.After;
  4. import org.junit.Before;
  5. import org.junit.Test;
  6.  
  7.  
  8.  
  9.  
  10.  public class testAddPatient  extends SeleneseTestCase
  11.  {
  12.  
  13.  
  14.         public static Integer NUMBER_OF_OBJECT = 0;
  15.         public Integer count;
  16.         String user_name;
  17.         String password;
  18.         public testAddPatient()
  19.          {
  20.         super();
  21.         count = NUMBER_OF_OBJECT++;
  22.          }
  23.  
  24.     @Before
  25.    public void setUp() throws Exception
  26.    {
  27.      
  28.      selenium = new DefaultSelenium("localhost", 4444, "*googlechrome","http://192.168.1.118:8080/");
  29.      selenium.start();
  30.    }
  31.  
  32.    
  33.    
  34.     @Test
  35.     public void test() throws Exception
  36.     {
  37.     //openurl
  38.      selenium.windowMaximize();
  39.      selenium.open("http://192.168.1.118:8080");
  40.    
  41.      selenium.waitForPageToLoad("2000");
  42.    
  43.      selenium.click("link=here");
  44.    
  45.    
  46.     //login
  47.          selenium.waitForPageToLoad("30000");
  48.  
  49.        
  50.  
  51.      
  52.        if(count == 0)
  53.     {
  54.     selenium.type("id=frmLogin:txtUserName","kaustubhk");
  55.     selenium.type("id=frmLogin:txtPassword","kaustubh123");
  56.     }
  57.        
  58.     else if(count==1)
  59.     {
  60.     selenium.type("id=frmLogin:txtUserName","sriharis");
  61.     selenium.type("id=frmLogin:txtPassword","asdf1234");
  62.     }
  63.  
  64.     else if(count==2)
  65.     {
  66.     selenium.type("id=frmLogin:txtUserName","sheetalk");
  67.     selenium.type("id=frmLogin:txtPassword","sheetal123");
  68.     }
  69.        
  70.     else if(count==3)  
  71.     {
  72.     selenium.type("id=frmLogin:txtUserName","chittak");
  73.     selenium.type("id=frmLogin:txtPassword","chitta123");
  74.     }
  75.        
  76.     else if(count==4)
  77.     {
  78.     selenium.type("id=frmLogin:txtUserName","gayatrip1");
  79.     selenium.type("id=frmLogin:txtPassword","asdf1234");
  80.     }
  81.  
  82.     else if(count==5)
  83.     {
  84.     selenium.type("id=frmLogin:txtUserName","vikasm");
  85.     selenium.type("id=frmLogin:txtPassword","asdf1234");
  86.     }
  87.        
  88.     .
  89.     .
  90.     .
  91.     .
  92.     .
  93.     .
  94.     .
  95.     .
  96.     .
  97.     .
  98.     .
  99.  
  100.        
  101.     else if(count==17)
  102.     {
  103.     selenium.type("id=frmLogin:txtUserName","vidyap");
  104.     selenium.type("id=frmLogin:txtPassword","vidya123");   
  105.     }
  106.        
  107.        
  108.        
  109.        
  110. selenium.click("name=frmLogin:j_idt17");
  111. Thread.sleep(2000);
  112.  
  113.     if(selenium.isElementPresent("link=Login Forcefully"))
  114.     {
  115.     selenium.click("link=Login Forcefully");
  116.     }
  117.  
  118. selenium.waitForPageToLoad("40000");
  119.  
  120. //Add new patient
  121.  
  122.         selenium.click("css=input.addptBtn");
  123.         selenium.type("id=txtAddPtFname", "Himani");
  124.     selenium.type("id=txtAddPtLname", "Paur");
  125.     selenium.select("css=select[name*='j_idt']", "Miss");
  126.     selenium.type("id=txtAddPtAge", "30");
  127.         selenium.select("id=ddAddPtGender", "label=Female");
  128.         selenium.type("id=txtAddPtAreaCode", "12321");
  129.         selenium.type("id=txtAddPtHomePhone", "32132132");
  130.    
  131.     selenium.click("//input[@value='Add Patient']");
  132.    
  133.     selenium.click("//input[@value='Ok']");
  134.     selenium.type("name=txtAddApptCC","acidity");
  135.    
  136.     selenium.click("//input[@value='Schedule Appointment']");
  137.     Thread.sleep(5000);
  138.        
  139.      
  140. //Add new patient
  141.    selenium.click("css=input.addptBtn");
  142.    selenium.type("id=txtAddPtFname", "Ketaki");
  143.    selenium.type("id=txtAddPtLname", "Paudwal");
  144.    selenium.select("css=select[name*='j_idt']", "Miss");
  145.    selenium.type("id=txtAddPtAge", "30");
  146.    selenium.select("id=ddAddPtGender", "label=Female");
  147.    selenium.type("id=txtAddPtAreaCode", "12321");
  148.    selenium.type("id=txtAddPtHomePhone", "32132132");
  149.    
  150.    selenium.click("//input[@value='Add Patient']");
  151.    selenium.click("//input[@value='Ok']");
  152.    selenium.type("name=txtAddApptCC","acidity");
  153.  
  154.    selenium.click("//input[@value='Schedule Appointment']");
  155.    Thread.sleep(5000);
  156.        
  157. //Add new patient
  158.    selenium.click("css=input.addptBtn");
  159.    selenium.type("id=txtAddPtFname", "Shriya");
  160.    selenium.type("id=txtAddPtLname", "Dhani");
  161.    selenium.select("css=select[name*='j_idt']", "Miss");
  162.    selenium.type("id=txtAddPtAge", "30");
  163.    selenium.select("id=ddAddPtGender", "label=Female");
  164.    selenium.type("id=txtAddPtAreaCode", "12321");
  165.    selenium.type("id=txtAddPtHomePhone", "32132132");
  166.  
  167.    selenium.click("//input[@value='Add Patient']");
  168.    selenium.click("//input[@value='Ok']");
  169.    selenium.type("name=txtAddApptCC","acidity");
  170.    selenium.click("//input[@value='Schedule Appointment']");
  171.    Thread.sleep(5000);
  172.        
  173. //Add new patient
  174.    selenium.click("css=input.addptBtn");
  175.    selenium.type("id=txtAddPtFname", "Meena");
  176.    selenium.type("id=txtAddPtLname", "Londhe");
  177.    selenium.select("css=select[name*='j_idt']", "Miss");
  178.    selenium.type("id=txtAddPtAge", "30");
  179.    selenium.select("id=ddAddPtGender", "label=Female");
  180.    selenium.type("id=txtAddPtAreaCode", "12321");
  181.    selenium.type("id=txtAddPtHomePhone", "32132132");
  182.    
  183.    selenium.click("//input[@value='Add Patient']");
  184.    selenium.click("//input[@value='Ok']");
  185.    selenium.type("name=txtAddApptCC","acidity");
  186.    selenium.click("//input[@value='Schedule Appointment']");
  187.    Thread.sleep(5000);
  188.        
  189. ///Add new patient
  190.  
  191.    selenium.click("css=input.addptBtn");
  192.    selenium.type("id=txtAddPtFname", "Pritisha");
  193.    selenium.type("id=txtAddPtLname", "Sowani");
  194.    selenium.select("css=select[name*='j_idt']", "Miss");
  195.    selenium.type("id=txtAddPtAge", "30");
  196.    selenium.select("id=ddAddPtGender", "label=Female");
  197.    selenium.type("id=txtAddPtAreaCode", "12321");
  198.    selenium.type("id=txtAddPtHomePhone", "32132132");
  199.    
  200.    selenium.click("//input[@value='Add Patient']");
  201.    selenium.click("//input[@value='Ok']");
  202.    selenium.type("name=txtAddApptCC","acidity");
  203.    selenium.click("//input[@value='Schedule Appointment']");
  204.    Thread.sleep(5000);
  205.     }
  206.    
  207. @After
  208.  
  209.         public void tearDown() throws Exception
  210.         {
  211.            selenium.click("id=actLogout");
  212.         }
  213.  
  214. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement