PlanetJava
Custom Search

java-testng-user
[Top] [All Lists]

@DataProvider - sharing data loaded in each iteration in differernt tes

Subject: @DataProvider - sharing data loaded in each iteration in differernt test methods
Date: Tue, 10 Aug 2010 21:04:57 -0700 (PDT)
Hi there,
I'm uploading test data from an excel file (see code below) and want
to re-use the data from each iteration in different tests. Current
behavior is data is only used by method LandingPage and not by any of
the other ones.
thanks
public class QADiscoveryTool extends SeleneseTestCase {
          @BeforeClass
          public void setUp() throws Exception {
                // Selenium Set Up code here
          }
          //Data Provider
          @DataProvider(name = "excelLoader")
           public Object[][] createData1() throws Exception {
                 Object[][] retObjArr = getTableArray("test\\Resources\\Data\
\DL_SmokeTest_DataInput.xls", "DataInput", "imdbTestData1");
          return (retObjArr);
                  }
          public String[][] getTableArray(String xlFilePath, String
sheetName, String tableName){
              String[][] tabArray=null;
              try{
                    Workbook workbook = Workbook.getWorkbook(new
File(xlFilePath));
                    Sheet sheet = workbook.getSheet(sheetName);
                    int startRow,startCol, endRow, endCol,ci,cj;
                    Cell tableStart=sheet.findCell(tableName);
                    startRow=tableStart.getRow();
                    startCol=tableStart.getColumn();
                    Cell tableEnd= sheet.findCell(tableName, startCol
+1,startRow+1, 100, 64000,  false);
                    endRow=tableEnd.getRow();
                    endCol=tableEnd.getColumn();
                    System.out.println("startRow="+startRow+", endRow="+endRow
+", " + "startCol="+startCol+", endCol="+endCol);
                    tabArray=new String[endRow-startRow-1][endCol-
startCol-1];
                    ci=0;
                    for (int i=startRow+1;i<endRow;i++,ci++){
                          cj=0;
                          for (int j=startCol+1;j<endCol;j++,cj++){
                                tabArray[ci]
[cj]=sheet.getCell(j,i).getContents();
                          }
                          }
                    }
                    catch (Exception e)    {
                          System.out.println("error in getTableArray()");
                    }
                    return(tabArray);
              }
                @Test (dataProvider = "excelLoader")
                  public void LandingPage (String Address, String Apartment, 
String
City, String State, String ZipCode, String NPA, String NXX, String
Suffix) throws Exception {
                                for (int second = 0;; second++) {
                                        if (second >= 60) break;
                                        try { if 
(selenium.isVisible("dl_addressInput")) break; } catch
(Exception e) {}
                                        Thread.sleep(1000);
                                }
                                selenium.type("dl_addressInput", Address);
                                selenium.type("dl_zipCodeInput", ZipCode);
                                selenium.click("compareNow");
                                selenium.waitForPageToLoad("240000");
                                  }
          @Test(dependsOnMethods = "LandingPage", dataProvider =
"excelLoader")
          public void DispatchPage(String Address, String Apartment, String
City, String State, String ZipCode, String NPA, String NXX, String
Suffix) throws Exception {
                        for (int second = 0;; second++) {
                                if (second >= 30) break;
                                try { if 
(selenium.isVisible("phone_entry_submit"))     {
                                        boolean ldata = true;
                                        if (NPA.length()!= 3) ldata = false;
                                        if (NXX.length()!= 3) ldata = false;
                                        if (Suffix.length()!= 4) ldata = false;
                                        if (ldata){
                                        selenium.type("npa", NPA);
                                        selenium.type("nxx", NXX);
                                        selenium.type("suffix", Suffix);}
                                        selenium.click("phone_entry_submit");
                                        break; }
                                } catch (Exception e) {}
                                Thread.sleep(1000);
                        }
                // more Selenium code here
          }
          @Test(dependsOnMethods = "DispatchPage")
          public void ShowOffersPage() {
                // more Selenium code here
          }
          @Test (dependsOnMethods = "ShowOffersPage")
          public void PlaceOrderPage() {
                // more Selenium code here
          }
          @Test(dependsOnMethods = "PlaceOrderPage")
          public void OrderConfirmationPage() {
                // more Selenium code here
          }
                @AfterClass
              public void tearDown(){
                    selenium.close();
                    selenium.stop();
              }
}
-- 
You received this message because you are subscribed to the Google Groups 
"testng-users" group.
To post to this group, send email to 
testng-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To unsubscribe from this group, send email to 
testng-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit this group at 
http://groups.google.com/group/testng-users?hl=en.
msgmiddle
<Prev in Thread] Current Thread [Next in Thread>
  • @DataProvider - sharing data loaded in each iteration in differernt test methods,
    • Re: @DataProvider - sharing data loaded in each iteration in differernt test methods
      • Re: @DataProvider - sharing data loaded in each iteration in differernt test methods
        • Re: @DataProvider - sharing data loaded in each iteration in differernt test methods
Current Sitemap | © 2012 planetjava | Contact | Privacy Policy