11/20/15

Selenium FAQ-Part4

Q. How to configure the framework in to eclipse?
A. Following are the steps to configure framework in eclipse:
  • Extract the provided zip folder
  • Open eclipse and create a new project using the extracted zip folder
  • Run the sample test script RegistrationTest.java by using the JUnit option
  • Create new test scripts in the folder 'TestScipts' and run them using JUnit option
Q. Does the framework work only for java language?
A. The framework is made in Java language but is language agnostic and can be used with any language.
Q. What is meant by Page Object Model design?
A. Page Object Model is a simple design pattern that models each page (or page chunk) as a class object that other classes / objects can interact with.
Q. Where can I see the generated reports?
A. We can see the HTML view of generated reports:
  • Run the build.xml as Ant Build
  • Refresh the project and open the Reports folder
  • From the Reports folder, open the index.html file with Web Browser
Q. How can I change the browser to be used for running the test scripts?
A. Following are the steps:
  • Go to the config folder
  • Open the “gui_automation.properties” file
  • Uncomment the needed browser configuration and comment the not needed browser in this file and save the file
Q. Does WebDriver support file uploads?
A. Yes, it is possible if you call WebElement#sendKeys("/path/to/file") on a file upload element. Make sure you don't use WebElement#click() on the file upload element or the browser will hang.
Q. What input fields have been targeted in v3 of the framework using parameterization
A. Text boxes, radio buttons, drop downs, check boxes, auto-suggest search drop down, and file upload.
Q. How can I handle multiple windows?
A. You can handle multiple windows using the "WebDriver.switchTo().window()" method - here window name is required. If the name is not known, you can use "WebDriver.getWindowHandles()" to obtain a list of known windows and then switch to a specific window.
Q. Can I make webdriver to wait for some event on default?
A. Yes.
Example: new WebDriverWait(driver,20).until(ExpectedConditions.presenceOfElementLocated(B y.id("loginBox")))
Q. Does the framework support the .xlsx extension files for parameterization?
A. Yes. We have provided support for .xlsx extension files i.e. 2007-2010 format, using Apache POI.
Q. When I can use implicit and explicit wait?
A. Implicit wait will be used when you need to wait for all elements in script, while Explicit wait method will be used only for particular specified elements. Explicit wait will be preferred for dynamically loading ajax elements.
Implicit wait Example:
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
Explicit Wait Example:
public static WebElement explicitWait(WebDriver driver,By by){
WebDriverWait wait = new WebDriverWait(driver, 30); 
wait.until(ExpectedConditions.presenceOfElementLocated(by)); }
Q. Which command should be used to quit WebDriver instance?
A. The quit() method is used to quit WebDriver instance. That is:
driver.quit();
Q. How can I drag element from one position and drop to second position?
A. This event can be implemented by using Action interface. Example: 
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(someElement).
moveToElement(otherElement).release(otherElement).build();
dragAndDrop.perform();
Q. How can I move backwards or forwards in browser's history in Webdriver?
A. You can move backwards and forwards in browser’s history as below:
//To go backward
driver.navigate().back();
//To go forward
driver.navigate().forward();
Q. How can I get title of the window?
A. You can get the title of the window by using getTitle() method:
String title = driver.getTitle(); 
System.out.println("Title of the page is "+title);
Q. How to Maximize the browser to screen size?
A. To maximize the browser window to screen size Toolkit.getScreenSize() method is used:
Toolkit toolkit = Toolkit.getDefaultToolkit(); 
Dimension screenResolution = new Dimension((int) 
toolkit.getScreenSize().getWidth(), (int) 
toolkit.getScreenSize().getHeight()); 
driver.manage().window().setSize(screenResolution);
Q. How to handle pageload time in webdriver?
A. You can set the PageLoadTimeout value to whatever you need using:
driver.Timeouts.PageLoadTimeout(XX, SECONDS)
where XX is the number of seconds you want the timeout to be set to.
Q. How can i get text from alert window ?
A. To get text from alert box, first you have to switch on alert, and then you can use getText method:
Alert alert = driver.switchTo().alert();
// Get the text from the alert
String alertText = alert.getText();






0 comments:

Post a Comment