Thursday, December 26, 2013

Selenium RC Tutorials




public static void main(String[] args)
{
// TODO Auto-generated method stub

Selenium selenium = new DefaultSelenium("localhost", 1244, "firefox", "http://www.google.co.in");



selenium.addCustomRequestHeader(arg0, arg1);
              selenium.addLocationStrategy(arg0, arg1);
              selenium.addScript(arg0, arg1);
              selenium.addSelection(arg0, arg1);
              selenium.allowNativeXpath(arg0);
              selenium.altKeyDown();
              selenium.altKeyUp();
              selenium.answerOnNextPrompt(arg0);
              selenium.assignId(arg0, arg1);
              selenium.attachFile(arg0, arg1);
              selenium.captureEntirePageScreenshot(arg0, arg1);
              selenium.captureEntirePageScreenshotToString(arg0);
              selenium.captureNetworkTraffic(arg0);
              selenium.captureScreenshot(arg0);
              selenium.captureScreenshotToString();
              selenium.check(arg0);
              selenium.chooseCancelOnNextConfirmation();
              selenium.chooseOkOnNextConfirmation();
              selenium.click(arg0);
              selenium.clickAt(arg0, arg1);
              selenium.close();
              selenium.contextMenu(arg0);
              selenium.contextMenuAt(arg0, arg1);
              selenium.controlKeyDown();
              selenium.controlKeyUp();
              selenium.createCookie(arg0, arg1);
              selenium.deleteAllVisibleCookies();
              selenium.deleteCookie(arg0, arg1);
              selenium.deselectPopUp();
              selenium.doubleClick(arg0);
              selenium.doubleClickAt(arg0, arg1);
              selenium.dragAndDrop(arg0, arg1);
              selenium.dragAndDropToObject(arg0, arg1);
              selenium.dragdrop(arg0, arg1);
              selenium.equals(arg0);
              selenium.fireEvent(arg0, arg1);
              selenium.focus(arg0);
              selenium.getAlert();
              selenium.getAllButtons();
              selenium.getAllFields();
              selenium.getAllLinks();
              selenium.getAllWindowIds();
              selenium.getAllWindowNames();
              selenium.getAllWindowTitles();
              selenium.getAttribute(arg0);
              selenium.getAttributeFromAllWindows(arg0);
              selenium.getBodyText();
              selenium.getClass();
              selenium.getConfirmation();
              selenium.getCookie();
              selenium.getCookieByName(arg0);
              selenium.getCssCount(arg0);
              selenium.getCursorPosition(arg0);
              selenium.getElementHeight(arg0);
              selenium.getElementIndex(arg0);
              selenium.getElementPositionLeft(arg0);
              selenium.getElementPositionTop(arg0);
              selenium.getElementWidth(arg0);
              selenium.getEval(arg0);
              selenium.getExpression(arg0);
              selenium.getHtmlSource();
              selenium.getLocation();
              selenium.getLog();
              selenium.getMouseSpeed();
              selenium.getPrompt();
              selenium.getSelectedId(arg0);
              selenium.getSelectedIds(arg0);
              selenium.getSelectedIndex(arg0);
              selenium.getSelectedIndexes(arg0);
              selenium.getSelectedLabel(arg0);
              selenium.getSelectedLabels(arg0);
              selenium.getSelectedValue(arg0);
              selenium.getSelectedValues(arg0);
              selenium.getSelectOptions(arg0);
              selenium.getSpeed();
              selenium.getTable(arg0);
              selenium.getText(arg0);
              selenium.getTitle();
              selenium.getValue(arg0);
              selenium.getWhetherThisFrameMatchFrameExpression(arg0, arg1);
              selenium.getWhetherThisWindowMatchWindowExpression(arg0, arg1);
              selenium.getXpathCount(arg0);
              selenium.goBack();
              selenium.hashCode();
              selenium.highlight(arg0);
              selenium.ignoreAttributesWithoutValue(arg0);
              selenium.isAlertPresent();
              selenium.isChecked(arg0);
              selenium.isConfirmationPresent();
              selenium.isCookiePresent(arg0);
              selenium.isEditable(arg0);
              selenium.isElementPresent(arg0);
              selenium.isOrdered(arg0, arg1);
              selenium.isOrdered(arg0, arg1);
              selenium.isPromptPresent();
              selenium.isSomethingSelected(arg0);
              selenium.isTextPresent(arg0);
              selenium.isVisible(arg0);
              selenium.keyDown(arg0, arg1);
              selenium.keyDownNative(arg0);
              selenium.keyPress(arg0, arg1);
              selenium.keyPressNative(arg0);
              selenium.keyUp(arg0, arg1);
              selenium.keyUpNative(arg0);
              selenium.metaKeyDown();
              selenium.metaKeyUp();
              selenium.mouseDown(arg0);
              selenium.mouseDownAt(arg0, arg1);
              selenium.mouseDownRight(arg0);
              selenium.mouseDownRightAt(arg0, arg1);
              selenium.mouseMove(arg0);
              selenium.mouseMoveAt(arg0, arg1);
              selenium.mouseOut(arg0);
              selenium.mouseOver(arg0);
              selenium.mouseUp(arg0);
              selenium.mouseUpAt(arg0, arg1);
              selenium.mouseUpRight(arg0);
              selenium.mouseUpRightAt(arg0, arg1);
              selenium.notify();
              selenium.notifyAll();
              selenium.open(arg0);
              selenium.open(arg0, arg1);
              selenium.openWindow(arg0, arg1);
              selenium.refresh();
              selenium.removeAllSelections(arg0);
              selenium.removeScript(arg0);
              selenium.removeSelection(arg0, arg1);
              selenium.retrieveLastRemoteControlLogs();
              selenium.retrieveLastRemoteControlLogs();

Sunday, December 22, 2013

Core Java FAQs


  1. Q. what is an object?

    A.object is anything that is really exists.

  2. Q. what is a method and class?

    A.class is a blue print/ group name /collection of objects. method represents group of statements that perform a task and it is reusable component.

  3. Q. What is the difference between String and Array

    A.String it is a collection of characters. Array is a collection of elements which are same types examples are integer/float/double array ex:int[]a={10,12,3,13};

  4. Q. How to split a string

    A.By using split() method we can split the string but it returns String array. String[] str1=str.split(" ")

  5. Q. What is Overloading

    A.Writing two or more methods in a class in such a way that each method having the same name with different parameters is called Overloading

  6. Q. What is Overriding

    A.Writing two or more methods in super class and sub class such a way that each method has same name and same signatures and same return types.

  7. Q. What is Inheritance

    A.acquiring(copying) properties and methods from one class to another class.

  8. Q. How to Reverse string with out using reverse method

    A.
    String str="Nagesh";
    for (int i = str.length()-1; i >= 0; i--) {
    System.out.println(str.charAt(i));
    }

  9. Q. What is Encapsulation

    A.

Manual Testing FAQs

  1. Q. What is Testing

    A.Testing is a process of identifying the bugs on the project/product. Test engineer is responsible to deliver the quality project/Product

  2. Q. What phases are available in SDLC

    A.Six phases are available 1. Requirement phase 2. Analysis phase 3. Design phase 4. Implementation/Coding phase 5. Testing phase 6. Delivery and Maintenance phase

  3. Q. What is the difference between Defect, Bug and Issue

    A.Defect:  Design related faults are known as Defects.
    Ex: GUI related faults are known as Defects

    Bug: This is programmers fault.
    Ex: Functional related faults are known as Bugs

    Issue: This is the customer's fault. This is a situation where the software is not doing something that the customer or user wants it to do, and so as a result the requirements of the design need to be changed

  4. Q. Difference between Waterfall, V-model and Agile Model?

    A.

  5. Q. What is Re-testing testing and Regression testing?

    A.

  6. Q. What is the difference between Sanity and smoke Testing?

    A.

  7. Q. What is Load, Performance and Stress Testing?

    A.

  8. Q. What is Usability testing?

    A.

  9. Q. What is UAT?

    A.

  10. Q. What is ECP and BVA?

    A.

  11. Q. functional system testing? Explain in detail

    A.

  12. Q. Draw differences between web application testing and client server testing.

    A.

  13. Q. Explain in detail what is integration testing and Regression testing

    A.

  14. Q. Explain the difference between defect, bug and error. Give an example

    A.

  15. Q. Explain the difference between test scenario and test case

    A.

  16. Q. Draw differences between QC and QA?

    A.

  17. Q. In case of defects in the software, how are priority and severity defined?

    A.

  18. Q. What is the difference between priority in test cases and priority in bugs

    A.

  19. Q. What do you write in a test plan?

    A.

  20. Q. What does ‘testing’ mean?

    A.

  21. Q. What is AUT?

    A.

  22. Q. What is Ad Hoc Testing?

    A.

  23. Q. What is Alpha Testing and Beta Testing?

    A.

  24. Q. What is Compatibility Testing?

    A.

  25. Q. What is End-to-End testing?

    A.

  26. Q. What is Endurance Testing (or Soak Testing)?

    A.

  27. Q. What is Localization Testing?

    A.

  28. Q. What is Monkey Testing (or Gorilla Testing)?

    A.

  29. Q. Why you want to change the organization?

    A.

  30. Q. If I offer less package, will you join in my organization?

    A.

  31. Q. Explain the bug which is High Severity and Low priority ?

    A.

  32. Q. Explain the bug which is Low Severity and High priority ?

    A.

  33. Q. Brief about your self?

    A.

  34. Q. Write 5 positive and negative test cases for mobile

    A.

  35. Q. Write 5 negative test cases on bike

    A.

General Testing FAQs


  1. Q. How many Test cases can be written in a day

    A.It always depends on the project and requirements. But on and average we can write 60 to 70 testcases per day.

  2. Q. How many Testcases can be executed manually per day

    A.It depends on the project. But we have two approaches here.

    1. If you have written the test cases, so you will be knowing functional knowledge of the application. So we can execute 70 to 80 test cases per day

    2. If you have not written the test cases, for example client has given the test cases. In this situation we can execute 40 to 50 test cases per day

  3. Q. How to share or sent a file (size-50MB) in the organization

    A.If the file size is more, then we can't send it through  a mail. We have two options
    1. Share the file, by right clicking on it and click on Properties, then select sharing option

    2. In the organizations we will be having "Common Repository". Copy the file and paste it in the Common Repository, so any one can access it

Web driver Scripts

Capture Screen Shots.

public class CaptureScreenshot {
public WebDriver driver;

public void captureScreenShot(String str) throws Exception{
DateFormat dateFormat = new SimpleDateFormat("yyyy_MMM_dd HH_mm_ss");
  Date date = new Date();
String time=dateFormat.format(date);
File f = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(f, new File("D:\\Workspace_Weekend_14Dec\\"+str+time+".jpg"));
}
  @Test
  public void f() throws Exception{
 driver=new FirefoxDriver();
 driver.get("http://spicejet.com");
 captureScreenShot("Homepage");
driver.findElement(By.linkText("Book a Flight")).click();
captureScreenShot("BookaFlight");
  }
}

2. Drop down Validation
package testNG;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class DropdownValidation {
public WebDriver driver;
  @Test
  public void f() {
 /*  String s[]=new String[15];
 List<String> s1=new ArrayList<String>();*/
 
 driver.get("http://spicejet.com");
 driver.findElement(By.linkText("Book a Flight")).click();
 String str="ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListPassengerType_ADT";
List<WebElement> s=new Select(driver.findElement(By.id(str))).getOptions();
System.out.println(s.size());
for (int i = 0; i < s.size(); i++) {
//System.out.println(s.get(i).getText());
if(s.get(i).getText().equalsIgnoreCase("5 Adults"))
{
System.out.println(s.get(i).getText());
new Select(driver.findElement(By.id(str))).selectByVisibleText(s.get(i).getText());
}
}

  }
  @BeforeTest
  public void beforeTest() {
 System.setProperty("webdriver.chrome.driver", "D:\\Lib\\chromedriver.exe");
 driver=new ChromeDriver();
  }

  @AfterTest
  public void afterTest() {
  }

}

3. Mail Login register

package testNG;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class Mail_Login_Register {
public WebDriver driver;
  @Test
  public void verifyLogin() throws Exception{
driver.get("http://mail.in.com");
driver.findElement(By.id("f_id")).sendKeys("jan30selenium");
driver.findElement(By.id("f_pwd")).sendKeys("selenium");
driver.findElement(By.cssSelector("input.signin")).click();
Thread.sleep(4000);
driver.findElement(By.linkText("Sign out")).click();
  }
@Test //Test Scenario
public void verifyRegister() throws Exception{
driver.get("http://mail.in.com");
driver.findElement(By.cssSelector("input.registernow")).click();
driver.findElement(By.id("fname")).sendKeys("Nagesh");
new Select(driver.findElement(By.id("day"))).selectByVisibleText("10");
new Select(driver.findElement(By.id("month"))).selectByVisibleText("Jun");
new Select(driver.findElement(By.id("year"))).selectByVisibleText("1983");
Thread.sleep(1000);
driver.findElement(By.xpath("(//input[@name='radiousername'])[3]")).click();
Thread.sleep(3000);
driver.findElement(By.id("password")).sendKeys("nag123");
driver.findElement(By.id("repassword")).sendKeys("nag123");
driver.findElement(By.id("altemail")).sendKeys("nag@gmail.com");
driver.findElement(By.id("imageField")).click();
Thread.sleep(3000);
driver.findElement(By.xpath("(//input[@id='gender'])[2]")).click();
}
  @BeforeTest
  public void beforeTest() {
 System.setProperty("webdriver.chrome.driver", "D:\\Lib\\chromedriver.exe");
 driver=new ChromeDriver();
  }

  @AfterTest
  public void afterTest() {
 driver.quit();
  }

}

4. Print All links

package testNG;

import java.util.ArrayList;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class PrintAllLinks {
public WebDriver driver;
  @Test
  public void f() {
/*  String s[]=new String[15];
 List<String> s1=new ArrayList<String>();*/
 driver.get("http://spicejet.com");
 List<WebElement> str=driver.findElements(By.tagName("a"));
 System.out.println(str.size());
 for (int i = 0; i < str.size(); i++) {
System.out.println(str.get(i).getText());//str[i]
}
 
  }
  @BeforeTest
  public void beforeTest() {
 System.setProperty("webdriver.chrome.driver", "D:\\Lib\\chromedriver.exe");
 driver=new ChromeDriver();
  }

  @AfterTest
  public void afterTest() {
  }

}

5. Spice jet Pop ups

package testNG;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class Spicejet_Popup {
public WebDriver driver;
  @Test(description="Verify URL")
  public void test1() {
driver.get("http://spicejet.com");  
  }
  @Test(description = "Verify BookAFlight")
  public void test2(){
driver.findElement(By.linkText("Book a Flight")).click();
  }
  @Test(description ="Verify Oneway search")
  public void test3() throws Exception{
 driver.findElement(By.id("ControlGroupSearchView_AvailabilitySearchInputSearchView_OneWay")).click();
driver.findElement(By.id("ControlGroupSearchView_AvailabilitySearchInputSearchVieworiginStation1_CTXT")).click();
driver.findElement(By.linkText("Hyderabad (HYD)")).click();
Thread.sleep(1000);
driver.findElement(By.linkText("Bengaluru (BLR)")).click();
Thread.sleep(1000);
driver.findElement(By.linkText("26")).click();
Thread.sleep(1000);
new Select(driver.findElement(By.id("ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListPassengerType_ADT"))).selectByVisibleText("2 Adults");
new Select(driver.findElement(By.id("ControlGroupSearchView_AvailabilitySearchInputSearchView_DropDownListPassengerType_CHD"))).selectByVisibleText("2 Children");
driver.findElement(By.id("ControlGroupSearchView_AvailabilitySearchInputSearchView_ButtonSubmit")).click();
Thread.sleep(1000);
  }
  @Test(description ="Verify Confirmation Alert")
  public void test4(){
String str=driver.switchTo().alert().getText();
System.out.println(str);
driver.switchTo().alert().accept();
//driver.switchTo().alert().dismiss();
}
  @Test(description ="Verify popup")
public void test5() throws Exception{
 Thread.sleep(4000);
String windowName=driver.getWindowHandle();
driver.findElement(By.linkText("Currency Converter")).click();
driver.switchTo().window("converter");
new Select(driver.findElement(By.id("CurrencyConverterCurrencyConverterView_DropDownListBaseCurrency"))).selectByVisibleText("US Dollars(USD)");
new Select(driver.findElement(By.id("CurrencyConverterCurrencyConverterView_DropDownListConversionCurrency"))).selectByVisibleText("Indian Rupee(INR)");
driver.findElement(By.id("CurrencyConverterCurrencyConverterView_TextBoxAmount")).sendKeys("100");
Thread.sleep(1000);
//driver.findElement(By.id("ButtonCloseWindow")).click();
driver.close();
driver.switchTo().window(windowName);
new Select(driver.findElement(By.id("AvailabilitySearchInputSelectViewdestinationStation1"))).selectByVisibleText("Bhopal (BHO)");
}
  
  @BeforeTest //Precondition
  public void beforeTest() {
System.setProperty("webdriver.ie.driver", "D:\\Lib\\IEDriverServer.exe");  
 driver=new InternetExplorerDriver();
  }

  @AfterTest
  public void afterTest() {
 driver.quit();
  }

}

6. Split

package testNG;

import org.testng.annotations.Test;

public class Splits {
  @Test
  public void f() {
 /*String s1[]=new String[9];
 int j[]=new int[10];
 Object o[]=new Object[12];*/
 
 String str="seven,six,ten,one,two,three,four,five";
 String[] s=str.split(",");
 System.out.println(s.length);
for (int i = 0; i < s.length; i++) {
// System.out.println(s[i]);
if(s[i].equalsIgnoreCase("three"))
{
System.out.println(s[i]);
}
}
 
 
 
  }
}

7. Validation commands

package testNG;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import com.thoughtworks.selenium.Selenium;

public class ValidationCommands {
public WebDriver driver;
public Selenium selenium;
 @Test(enabled=false)
 public void f() throws Exception{
 driver.get("http://spicejet.com");
 driver.findElement(By.linkText("Book a Flight")).click();
driver.findElement(By.id("ControlGroupSearchView_AvailabilitySearchInputSearchView_OneWay")).click();
Thread.sleep(1000);
if(driver.findElement(By.id("custom_date_picker_id_2")).isDisplayed())
{
System.out.println("Available");
}else{
System.out.println("Not available");
}
 
  }
 @Test
 public void verifyUsername(){
 driver.get("http://mail.in.com");
/*if(driver.findElement(By.id("f_id")).isDisplayed()){
System.out.println("Available");
}else{
System.out.println("Not available");
}*/
Assert.assertEquals(selenium.isElementPresent("f_idcv"), true);
Assert.assertEquals(driver.findElement(By.id("f_idcv")).isDisplayed(), true);
if(selenium.isElementPresent("f_iddfg"))
{
 System.out.println("Available");
}else{
 System.out.println("Not available");
}
 }
  @BeforeTest
  public void beforeTest() {
 System.setProperty("webdriver.chrome.driver", "D:\\Lib\\chromedriver.exe");
 driver=new ChromeDriver();
 selenium=new WebDriverBackedSelenium(driver, "http://mail.in.com");
  }
}













Selenium FAQs

Selenium FAQs

  1. Q. Advantages of automation

    A.1. It saves time by executing the test cases with out manual effort 2. CTC(Cost to the company) can be saved 3. We can maintain Accuracy by repeating the same task in same manner 4. Bugs can be identified 5. We can report the bugs to the developer 6. We can ensure for quality


  2. Q. What are the components available in Selenium

    A.Selenium contains 4 components
    1. Selenium IDE 2. Selenium RC 3. Selenium WebDriver 4. Selenium Grid


  3. Q. Why should we go for Selenium instead of QTP

    A.1. Selenium is an opensource tool 2. It supports multiple languages like Java,C#,Perl,python,Ruby,HTML and PHP 3. It supports Firefox, IE, Google chrome, Safari and Opera 4. Supports Windows, Linux and Mac 5.Supports Web Applications 6. Its very flexible and extendable 7. It supports mobile web applications

  4. Q. What is Selenium IDE

    A.1. IDE stands for integrated Development environment. 2. It is for Record and Run the Scripts 3. Selenium IDE is an add on for Firefox 4. Its accountable for user actions 5. Recorded script can be viewed in all the supported languages like HTML, JAVA, C#, Ruby, Perl, Python 6. Recorded script can be run against other browsers also by using Selenium RC or Webdriver

  5. Q. How to capture screen shot in web driver.

    A.We can capture screenshot by using below two lines:

     File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
     FileUtils.copyFile(scrFile, new File("D:\\screenshot.png"));
                                           

  6. Q. How to maximize the browser in web driver.

    A.driver.manage().window().maximize();

  7. Q. How to run selenium server from command prompt.

    A.1. Go to command prompt 2. Give the path, Where the selenium server is saved ex: cd E:Library 3. Use the command "java -jar selenium-server-standalone-2.33.0.jar"

  8. Q. What is Selenium RC

    A.RC stands for Remote Control. It is a server and it launches browsers. It acts as API and library. It controls the entire automation

  9. Q. How many test cases can be automated per day.

    A.It always depends on the application and test cases. But on and average we can automate 5 to 6 test cases per day. Ex: 1. For analyzing the test cases 2. Developing the script 3. Debugging and executing the script 4. Stabilizing the script

  10. Q. What challenges you have faced with Selenium.

    A.Challenge means problems or issues 1. Maintaining synchronization is a challenge in Selenium. 2. Handling Desktop, Flex, Flash elements is challenge with selenium. 3. Proving the user defined Results a challenge 4. Taking the data from the application is a challenge

  11. Q. How to handle SSL Certificate issue in Firefox with Webdriver

    A.FirefoxProfile profile = new FirefoxProfile(); profile.setAcceptUntrustedCertificates(true); profile.setAssumeUntrustedCertificateIssuer(false); driver=new FirefoxDriver(profile);

  12. Q. What is the latest version of Selenium available

    A.selenium-server-standalone-2.37.0.jar

  13. Q. What is Automation

    A.The process of converting the manual test cases to test scripts by using any automation tool is known as Automation

  14. Q. How to handle SSL certication issue in IE

    A.Add the below command after opening the browser.

    driver.navigate().to("
    javascript:document.getElementById('overridelink').click()");

  15. Q. How to change the port number for Selenium RC

    A.Syntax:   -jar  seleniumJarfileName -port anyFourdigitNo
    Ex:  -jar selenium-server-standalone-2.33.0.jar -port 1234

  16. Q. How do you start Selenium RC from command prompt?

    A.1. Save the selenium jarfile (Selenium-server-standalone-2.34.0.jar) in any folder (Ex: D:/Library)
    2. Open command prompt
    3. Navigate to the path where you have saved the jar file and follow the below steps

    D:
    cd D:/Library
    java -jar selenium-server-standalone-2.34.0.jar


  17. Q. What locators available in Selenium RC

    A.ID
    Name
    CSS (Cascade style sheet)
    XPATH (Relative xpath and Absolute xpath)
    Dom
                                                                                                                                                                                                              


  18. Q. What locators available in Selenium Webdriver

    A.ID
    Name
    CSS
    XPath
    Classname
    TagName
    LinkText
    Partial Link Text

  19. Q. How to create DefaultSelenium object and what parameters needs to be pass

    A.DefaultSelenium selenium= new DefaultSelenium("localhost",4444,"*firefox","http://");

    localhost - It is the machine name and selenium server should be configured in the specific machine

    4444 - It's selenium port number.

    *firefox - Its is the command to launch firefox

    http:// - Protocol to open URL

  20. Q. How many types of Xpaths are available

    A.Xpath is two types:

    1. Relative XPath
    2. Absolute XPath

  21. Q. • What is the difference between single and double slash in Xpath.

    A."// " is the starting point of the Xpath.
    "/" will navigate into the tag

    Ex:  //html/head/body/div1/div2/......


  22. Q. How to handle Alerts and Confirmation Alerts in WebDriver

    A.We have to navigate to Alert or Confirmation as below,

    driver.switchTo().alert()

    To click OK or Cancel on Alert or Confirmation Alert then follow as below

    driver.switchTo().alert().accept();  -- To click OK

    driver.switchTo().alert().dismiss(); -- To click Cancel


  23. Q. How to Handle Popup in Webdriver

    A.We have to navigate to the popup as below

    driver.switchTo().window("Window Name");

    To navigate from Popup to main window

    driver.switchTo().window("Main Window Name");

  24. Q. How to handle dynamically changing popup in Webdriver

    A.Dynamic means the Name is not constant. It changes frequently

    Use the below approach to handle Dynamically changing popup

    Set<String> s=driver.getWindowHandles();
    Object popup[]=s.toArray();
    driver.switchTo().window(popup[1].toString());



  25. Q. Is it possible to handle multiple popups in Webdriver

    A.Yes.
    We can handle it by using the command

    driver.getWindowHandles();




  26. Q. How to capture window name

    A.driver.getWindowHandle();

  27. Q. How to launch Firefox, Safari and Opera with Webdriver

    A.
    Firefox, Safari and Opera we be launch by using below commands.
    WebDriver driver=new FirefoxDriver();
    WebDriver  driver=new OperaDriver();
    WebDriver  driver=new SafariDriver();

  28. Q. How to launch InternetExplorer.

    A.
    For IE, we need the supported "Internet Explorer Driver Server". It can be downloaded from the below site:
    Below code is to launch IE.
    System.setProperty("webdriver.ie.driver", "E:\\Library\\IEDriverServer.exe"); 
    driver=new InternetExplorerDriver();
    driver.get("http://gmail.com"); 




  29. Q. How to launch GoogleChrome

    A.
    For GoogleChrome, We need the supported "ChromeDriver" exe file. Can be downloaded from the below site:
    Below code is to launch GoogleChrome
    System.setProperty("webdriver.chrome.driver", "E:\\Library\\chromedriver.exe"); 
    driver=new ChromeDriver();
    driver.get("http://gmail.com");



  30. Q. Brief about the Disadvantages of Selenium

    A.Selenium supports Web applications. It doesn't support Desktop applications 

  31. Q. How to handle Deskptop, Flex and Flash objects in Selenium.

    A.
    We can use SIKULI as a add-on for Selenium to support Desktop, Flex and Flash objects
    Sikuli is an open source automation tool developed on JAVA


  32. Q. How to take data from excel(xls) file

    A.
    FileInputStream fi=new FileInputStream("Path of the excel file");
    Workbook w=Workbook.getWorkbook(fi);
    Sheet s=w.getSheet(0);
    It will read the excel file upto the sheet. To take the data from sheet, use below command,
    s.getCell(columnID, rowID).getContents())
    ex:
    s.getCell(0, 1).getContents();





  33. Q. How to create Excel file

    A.
    FileOutputStream fo=new FileOutputStream("Path to create xls file");
    WritableWorkbook wb=Workbook.createWorkbook(fo);
    WritableSheet ws=wb.createSheet("Results", 0);
    Label un=new Label(0,0,"Username");
    ws.addCell(un);
    wb.write();
    wb.close();

  34. Q. How to print data from notepad(txt file)

    A.
    File f=new File("E:\\data2.txt");
    FileReader fr=new FileReader(f);
    BufferedReader br=new BufferedReader(fr);
    String str;
    while((str=br.readLine())!=null)
    {
    System.out.println(str);
    }


  35. Q. How to create and write data into txt file

    A.  File f=new File("E:\\data2.txt");
      FileWriter fw=new FileWriter(f);
      BufferedWriter bw=new BufferedWriter(fw);
      bw.write("Nagesh");
      bw.newLine();
      bw.write("hyderabad");
      bw.newLine();
      bw.write("AP"); 
      bw.close();
      fw.close();

  36. Q. How to take or print data from XML file

    A.
    File fXmlFile = new File("D://file.xml");
     DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
     DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
     Document doc = dBuilder.parse(fXmlFile);
      doc.getDocumentElement().normalize();
     System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
      NodeList nList = doc.getElementsByTagName("staff");
      System.out.println("----------------------------");
      for (int temp = 0; temp < nList.getLength(); temp++) {
       Node nNode = nList.item(temp);
       System.out.println("\nCurrent Element :" + nNode.getNodeName());
       if (nNode.getNodeType() == Node.ELEMENT_NODE) {
        Element eElement = (Element) nNode;
        System.out.println("Staff id : " + eElement.getAttribute("id"));
       System.out.println("First Name : " + eElement.getElementsByTagName("firstname").item(0).getTextContent());
       System.out.println("Last Name : " + eElement.getElementsByTagName("lastname").item(0).getTextContent());
       System.out.println("Nick Name : " + eElement.getElementsByTagName("nickname").item(0).getTextContent());
       System.out.println("Salary : " + eElement.getElementsByTagName("salary").item(0).getTextContent());
       }
     }


  37. Q. What is Ant or Apache Ant

    A.Ant is a Java based build management tool.
    The process of converting the source code to software system (executable code) is known as build.
    There are number of steps to convert the source code to executable code. Ant will manages all the steps with Build.xml file.

    Steps to convert the Source code to software:
     1. Taking the source code from src repository
     2. Preparing a build area
     3. Compiling the source code
     4. Build the compiled code to executable code 

  38. Q. What is Maven

    A.Maven is also Java based build management tool. It is the advanced version of Ant.

  39. Q. What is the differences between Ant and Maven

    A.1. Maven is widely preferred than Ant. Ant is an older tool.
    2. Ant doesn't come with formal conventions such as a common project directory. Maven consists of conventions.
    3. Ant is procedural, Maven is declarative. It means in Ant, you have to specify the order what should have to be done, where as Maven takes care of all the directories once the files are stored in the pom.xml file.
    4. Another difference that can be seen is that Ant does not have a life cycle whereas Maven has a life cycle.
    5. The scripts in Ant are not reusable where as Maven comes with reusable plugins.

  40. Q. How do you handle the secured connection error in HTTPS?

    A.

  41. Q. How do you compare two strings or values are same.

    A.

  42. Q. What are the advantages and disadvantages of using Selenium as testing tool

    A.

  43. Q. Write down the logic for Palindrome

    A.

  44. Q. How do you handle Ajax controls using selenium? i. Eg. By typing in search engine how do you capture the auto suggestion

    A.

  45. Q. How do you select the 2nd item in a List box or drop down.

    A.

  46. Q. How do you identify an object using selenium?

    A.

  47. Q. Brief about your framework

    A.

  48. Q. What is the difference between assert and Verify Commands?

    A.

  49. Q. Explain about your reporting method

    A.

  50. Q. What is the difference between Selenium RC and Webdriver

    A.

  51. Q. What are all things can not be done through selenium IDE

    A.

  52. Q. Brief about Selenium Grid.

    A.

  53. Q. How to use selenium for performance testing

    A.

  54. Q. How to get all the links in http://google.co.in

    A.

  55. Q. Is it possible to handle multiple pop ups in selenium?

    A.

  56. Q. How is Selenium different from commercial browser automation tools?

    A.

  57. Q. Difference between Junit and TestNg framework

    A.

  58. Q. If the default port of selenium is busy then which port you use?

    A.

  59. Q. How much time we can save with automation

    A.

  60. Q. What is automation Lifecycle or Automation approach or automation plan

    A.

  61. Q. What is Abstraction

    A.

  62. Q. What is the difference between Performance, Load and Stress testing

    A.

  63. Q. Write a program to get all the text boxes in mail.in register page with webdriver

    A.

TestNG - Can i use the 2 different data providers to same @test methods in TestNG?

public Object [][] dp1 () { return new Object [][] { new Object [] { "a" , "b" }, new Obje...