Need help in data parameterization | Selenium Forum
A
Avijeet Posted on 18/10/2019

I have a scenario like below and need assist on this -

 

1. Need to login to application.

2. then do the parameterization from excel sheet.

3. log out from the application.

 

I'm able to perform this with multiple log in and log out but can we perform with single login instance ?

 

Below code is working with multiple log in.

 

public class test {

 

      

       @Test(dataProvider="getData")

      

      

       public void demo(String CDM_Code, String CDM_Name) throws Exception{

             

             

System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\Driver\\ChromeDriver.exe");

             

              WebDriver cd=new ChromeDriver();

             

              //cd.get("https://ppds-sit.int.thomsonreuters.com/PPDSWeb/Login.aspx");

             

              cd.get("http://ppds-sit.int.thomsonreuters.com/PPDSWeb/Login.aspx");

             

              cd.manage().window().maximize();

             

              cd.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

             

                            

           

              cd.findElement(By.xpath("//*[@id='ctl00_loginControls_txtUserName']")).sendKeys("test.developer");

              cd.findElement(By.xpath("//*[@id='ctl00_loginControls_txtPassword']")).sendKeys("Password3");

              cd.findElement(By.xpath("//*[@id='ctl00_loginControls_btnSubmit']")).click();

             

             

             

             

                                        

             

              WebElement WE1=cd.findElement(By.xpath("//*[@id='ctl02_MasterMenu-menuItem005']"));

             

              Actions act= new Actions(cd);

             

              act.click(WE1).build().perform();

             

             

              cd.findElement(By.xpath("//*[@id='ctl02_MasterMenu-menuItem005-subMenu-menuItem015']")).click();

             

             

             

              do{

             

             

                    

                     cd.findElement(By.xpath("//*[@id='btn_ContentDeliverysMaint_New']")).click();

              cd.findElement(By.xpath("//*[@id='txtContentDeliveryCode']")).sendKeys(CDM_Code);

              cd.findElement(By.xpath("//*[@id='txtContentDeliveryName']")).sendKeys(CDM_Name);

             

             

              cd.findElement(By.xpath("//*[@id='btn_ContentDeliverysMaint_Apply']")).click();

              cd.findElement(By.xpath("//*[@id='dlgControl_btnOK']")).click();

              cd.findElement(By.xpath("//*[@id='dlgControl_btnOK']")).click();

              Thread.sleep(4000);

             

              }while(CDM_Code !=" ");

             

              cd.close();

             

              }

         

       @DataProvider()

 

       public Object[][]getData(){

 

      

      

      

       //Total rows in the sheet

      

       Xls_Reader xls=new Xls_Reader("C:\\Selenium\\Files\\Content Delivery Model.xlsx");

      

       int rows=xls.getRowCount("CDM");

      

       System.out.println(rows);

      

      

       //Total column in the sheet

      

       int cols=xls.getColumnCount("CDM");

       System.out.println(cols);

      

       Object[][] data=new Object[rows-1][cols];

      

       int count=0; 

       for(int i=2;i<=rows;i++){ 

              for (int j=0;j<=cols-1;j++){

                    

                     data[count][j]= xls.getCellData("CDM", j, i);

      

                    

                     System.out.println(data[count][j]);

              }

             

              count++;     

 

}

      

      

      

       return data; 

 

       }

      

}

 

 


A
Ashish Thakur Replied on 18/10/2019

This will cause issues in parallel execution.

You can do that but we will not suggest you doing that.


A
Avijeet Replied on 19/10/2019

Is there any alternate way to perform this?


A
Ashish Thakur Replied on 21/10/2019

The simple way is to log in and perform actions and then logout.