How to open browser only once with diffrent test cases

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to open browser only once with diffrent test cases

Reddy
Hi  All,

I am new to this tool

I created different test cases within  one class (Like Invalid logon ,Blank login ,Invalid password,valid login and logout )

My scripts opening the browser for mutilple times   .(Each test cases opening each  browser )

Is that possible to write above test cases to open browser only one time (Not multiple times )


============================

          @Test
          public void blankusername() {
             
                 {
                        // TODO Auto-generated method stub
                        System.setProperty("webdriver.
chrome.driver", "C:\\Selenium\\chromedriver.exe");
                           ChromeDriver cd = new ChromeDriver();
                           cd.get("xxxxxxxx");                                            
                         
                           cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                           cd.findElement(By.id("gwt-debug-login-button")).click();
                 }
                                        
                    }

            
         
          @Test
          public void InvalidLogin() {
                 {
                        // TODO Auto-generated method stub
                        System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
                           ChromeDriver cd = new ChromeDriver();
                           cd.get("xxxxxxxx");
                                                           
                           cd.findElement(By.id("gwt-debug-username")).sendKeys("sathya");
                           cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                           cd.findElement(By.id("gwt-debug-login-button")).click();
                 }         
                    }

         

          @Test
          public void ValidLogin() {
                           
                 {
                        // TODO Auto-generated method stub
                        System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
                           ChromeDriver cd = new ChromeDriver();
                           cd.get("xxxxxxxx");
                                                           
                           cd.findElement(By.id("gwt-debug-username")).sendKeys("Administrator");
                           cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                           cd.findElement(By.id("gwt-debug-login-button")).click();
                 }             
                    }

         
          @Test
          public void Logout()      {
                // TODO Auto-generated method stub
                System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
                   ChromeDriver cd = new ChromeDriver();
                   cd.get("xxxxxxxx");
                                                   
                   cd.findElement(By.id("gwt-debug-username")).sendKeys("Administrator");
                   cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                   cd.findElement(By.id("gwt-debug-login-button")).click();
                   cd.manage().window().maximize();
                    cd.findElement(By.xpath(".//*[@id='gwtMenuContainer']/div/div/a")).click();
                                
            }
}

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How to open browser only once with diffrent test cases

Reddy
Issue Sorted @ Thanks

On Saturday, February 1, 2014 5:52:21 PM UTC, Reddy wrote:
Hi  All,

I am new to this tool

I created different test cases within  one class (Like Invalid logon ,Blank login ,Invalid password,valid login and logout )

My scripts opening the browser for mutilple times   .(Each test cases opening each  browser )

Is that possible to write above test cases to open browser only one time (Not multiple times )


============================

          @Test
          public void blankusername() {
             
                 {
                        // TODO Auto-generated method stub
                        System.setProperty("webdriver.
chrome.driver", "C:\\Selenium\\chromedriver.exe");
                           ChromeDriver cd = new ChromeDriver();
                           cd.get("xxxxxxxx");                                            
                         
                           cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                           cd.findElement(By.id("gwt-debug-login-button")).click();
                 }
                                        
                    }

            
         
          @Test
          public void InvalidLogin() {
                 {
                        // TODO Auto-generated method stub
                        System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
                           ChromeDriver cd = new ChromeDriver();
                           cd.get("xxxxxxxx");
                                                           
                           cd.findElement(By.id("gwt-debug-username")).sendKeys("sathya");
                           cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                           cd.findElement(By.id("gwt-debug-login-button")).click();
                 }         
                    }

         

          @Test
          public void ValidLogin() {
                           
                 {
                        // TODO Auto-generated method stub
                        System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
                           ChromeDriver cd = new ChromeDriver();
                           cd.get("xxxxxxxx");
                                                           
                           cd.findElement(By.id("gwt-debug-username")).sendKeys("Administrator");
                           cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                           cd.findElement(By.id("gwt-debug-login-button")).click();
                 }             
                    }

         
          @Test
          public void Logout()      {
                // TODO Auto-generated method stub
                System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
                   ChromeDriver cd = new ChromeDriver();
                   cd.get("xxxxxxxx");
                                                   
                   cd.findElement(By.id("gwt-debug-username")).sendKeys("Administrator");
                   cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                   cd.findElement(By.id("gwt-debug-login-button")).click();
                   cd.manage().window().maximize();
                    cd.findElement(By.xpath(".//*[@id='gwtMenuContainer']/div/div/a")).click();
                                
            }
}

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How to open browser only once with diffrent test cases

anand_raja
In reply to this post by Reddy
Try to declare property setting  in  @BeforeSuite or @BeforeClass annotation.



On Saturday, 1 February 2014 23:22:21 UTC+5:30, Reddy wrote:
Hi  All,

I am new to this tool

I created different test cases within  one class (Like Invalid logon ,Blank login ,Invalid password,valid login and logout )

My scripts opening the browser for mutilple times   .(Each test cases opening each  browser )

Is that possible to write above test cases to open browser only one time (Not multiple times )


============================

          @Test
          public void blankusername() {
             
                 {
                        // TODO Auto-generated method stub
                        System.setProperty("webdriver.
chrome.driver", "C:\\Selenium\\chromedriver.exe");
                           ChromeDriver cd = new ChromeDriver();
                           cd.get("xxxxxxxx");                                            
                         
                           cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                           cd.findElement(By.id("gwt-debug-login-button")).click();
                 }
                                        
                    }

            
         
          @Test
          public void InvalidLogin() {
                 {
                        // TODO Auto-generated method stub
                        System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
                           ChromeDriver cd = new ChromeDriver();
                           cd.get("xxxxxxxx");
                                                           
                           cd.findElement(By.id("gwt-debug-username")).sendKeys("sathya");
                           cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                           cd.findElement(By.id("gwt-debug-login-button")).click();
                 }         
                    }

         

          @Test
          public void ValidLogin() {
                           
                 {
                        // TODO Auto-generated method stub
                        System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
                           ChromeDriver cd = new ChromeDriver();
                           cd.get("xxxxxxxx");
                                                           
                           cd.findElement(By.id("gwt-debug-username")).sendKeys("Administrator");
                           cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                           cd.findElement(By.id("gwt-debug-login-button")).click();
                 }             
                    }

         
          @Test
          public void Logout()      {
                // TODO Auto-generated method stub
                System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
                   ChromeDriver cd = new ChromeDriver();
                   cd.get("xxxxxxxx");
                                                   
                   cd.findElement(By.id("gwt-debug-username")).sendKeys("Administrator");
                   cd.findElement(By.id("gwt-debug-password")).sendKeys("password");
                   cd.findElement(By.id("gwt-debug-login-button")).click();
                   cd.manage().window().maximize();
                    cd.findElement(By.xpath(".//*[@id='gwtMenuContainer']/div/div/a")).click();
                                
            }
}

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.