Posts

Showing posts from April, 2014

Selenium WebDriver: Working with a AutoSuggest box

Image
In this blog post , let us see how Mr.Web Driver is going to handle an Auto Suggest box . First and foremost point to be noted  is when you type a character(or) text  in the auto suggest box.we need to wait till application shows up some suggestions starting (or) containing the typed character. In the below illustrated example , Mr.Web Driver gives us an option to wait(using Explicit wait) until the suggestions are visible. public class Suggestbox { WebDriver driver=new FirefoxDriver();   @Test   public void cool() throws InterruptedException {  driver.get("http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwSuggestBox");  driver.manage().window().maximize();  WebDriverWait wait=new WebDriverWait(driver,10);  wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("gwt-debug-cwSuggestBox")));  //ENTER SOME VALUE IN SUGGEST BOX  driver.findElement(By.id("gwt-debug-cwSuggestB

Selenium WebDriver-Working with Listbox and Multi-Select Listbox

Image
We are going to see how to retrieve values of Single Select List box and How to Select multiple options in different ways on a Multi Select Listbox. import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.Select; import org.testng.annotations.Test; public class Listboxes { WebDriver driver=new FirefoxDriver();   @Test   public void Listboxtest() throws InterruptedException {  driver.get("http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwListBox");  driver.manage().window().maximize();  Thread.sleep(5000); //1. Single select list box -->first value will be the default value of the dropbox  WebElement lbox=driver.findElement(By.id("gwt-debug-cwListBox-dropBox"));  List<WebElement>

Selenium WebDriver-Opening a link of a webpage in a new tab and new page

Opening a link of a webpage in a new tab can be done by Ctrl (Key) + Click and opening a link in a  new page   by  Shift (Key) + Click. To perform this we need to import the package org.openqa.selenium.Keys. As you can observe in the below example. String selectAll = Keys.chord(Keys.SHIFT,Keys.RETURN); String tab=Keys.chord(Keys.CONTROL,Keys.RETURN); Wondering what is Keys and Chord ?  Keys is an enum inherited from java.lang.Enum<Keys> . Chord is a method used to simulate pressing many keys at once . CONTROL and SHIFT are Enum constants used to press Control key and Shift in the key board. import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Reporter; import org.testng.annotations.Test; public class Openinglinkintabpage { WebDriver driver=new FirefoxDriver();   String defaultwindow = "";   @Test   public void pagete

Selenium WebDriver Useful links

I found this link  very useful which has the frequently used Selenium Web Driver commands. For the Best Practices in Selenium ,Check out this ,