Posts

Showing posts from March, 2014

Selenium WebDriver -Handling JavaScript alerts

Handling JavaScript alerts of a web page using Selenium Webdriver is illustrated with an example below. On clicking on link/button in a webpage,we can shift the focus to java script alert/prompt by using driver.switchTo().alert() . import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; public class javascriptalerts {   @Test   public void auth()   {  WebDriver driver=new FirefoxDriver();  driver.get("http://the-internet.herokuapp.com/javascript_alerts");  //1.click on javascript alert     driver.findElement(By.xpath("html/body/div[2]/div/div/ul/li[1]/button")).click();  System.out.println(driver.switchTo().alert().getText());//To fetch the text in the alert  driver.switchTo().alert().accept();//clicking on OK button can be done using accept method.*/  //2.click on javascript confirm box  driver.findElemen

Habituate...

In this blogpost, I wanted to talk about a non-technical topic , which is applicable in day to day life and also helps building your career. I have read few books , blogs and watched you-tube videos on "how to be successful" or stuff like that. Every one constantly persist of being successful in their life or getting their dream job . But, the fact is that apart from having the desire to succeed in life . One needs to plan and implement small steps towards their goal. So, the emphasis should be on "Action". I have experienced a phase in my life when i feel like I haven't acted enough to attain my goal and one day when you talk to yourself , you feel like "What have i achieved over past 12 months?" - "What steps did i take to move towards my goal" . Getting out of such fear or frustration is tough. One of the best ways is to deal with it by making habits. Now that , you already know what a habit is ..i will share my methods to stick to h

Quality Center -OTA : Create a Test in QC Test Plan

In the previous blog post, we got to know about connecting to Quality Center using vb script /QTP. Now, we will create a test case in QC Test plan. Function Create_Test (QC_TestPlan_Path) Connect_QC( ) ' To check whether QC is connected Set treeMng = GLOBAL_QC_CONNECTION.TreeManager Set DestFolder=treeMng.NodeByPath(GLOBAL_QC_TESTPLAN_TREEPATH) Set TestF=DestFolder.TestFactory Set objTest = testF.AddItem(Null)       objTest.Field("TS_USER_01")="xxx" objTest.Field("TS_USER_04")="yyy" objTest.Field("TS_SUBJECT")=QC_TestPlan_Path ' subject objTest.Field("TS_USER_14")="cxxx" objTest.name ="TC_01_XXX" objTest.type ="QUICKTEST_TEST" 'ttype objTest.Field("TS_DESCRIPTION")="This is a sample test"                 objTest.Post ' By posting the test , a new test will be created  'To update the design steps - we need to check-o

Junit - Part 2

                                                                                                             Junit - Part 2 Test Data management is one of the essential things while doing test automation.We will see how parameterization is done in Junit. Both @RunWith and @ Parameter annotations are used to provide parameter values for the test. @Parameters will return a list and take an Object array as argument. Parameterization using Junit is explained with the below example. import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @RunWith(value=Parameterized.class) public class Test2  { private String Firstname,Lastname,Country; public Test2(String Firstname, String Lastname,String Country) { this.Firstname=Firstname; this.Lastname=Lastname; this.Country=Country; } @Parameters public static