Posts

To Find out whether a number is Armstrong number

  Armstrong number  is a number that is the sum of its own digits each raised to the power of the number of digits. Let us Look at how to find out whether the number is Armstrong using java. Note: The input is saved in Text file. Input: 7 181 153 Output: True False True import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.File; public class Armstrong {     public static void main (String[] args)  throws FileNotFoundException,NumberFormatException{          File file = new File(args[0]);     BufferedReader in = new BufferedReader(new FileReader(file));    int len;    String currentline;                               ...

Using ReportNg with Selenium WebDriver

Image
ReportNG is a simple HTML reporting plug-in for the  TestNG .  Why ReportNG? The ReportNG implementation maps each test class to a single <testsuite> element, resulting in one XML file per test class. This is different from the approach taken by the core TestNG implementation. What we need? To Start working with ReportNG , we need to download reportng-1.1.4 and velocity-dep-1.1.4 jar files which are latest versions till date. What Next? Add the above mentioned libraries to your Selenium +TestNg Project's build path. We need create testng.xml file which looks like <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="Suite" parallel="none">  <listeners>      <listener class-name="org.uncommons.reportng.HTMLReporter"/>  </listeners>   <test name="SmokeTest">       <clas...

Python in Eclipse

Image
Let us see how to set up Python in Eclipse IDE. Prerequisites :  Eclipse IDE  Python installed in your machine if not check this   link .  PyDev is a Python Development Environment (Python IDE plugin for Eclipse). Install PyDev via the Eclipse update manager . Refer :  http://pydev.org/updates or http://update-production-pydev.s3.amazonaws.com/pydev/updates/site.xml Launch Eclipse.Go to Help->Install New Software Click on Add. Enter any repository name and  the location as the link which mentioned above. Once you Add this. You will the repository added in the list of available software . Select the First check box “Py Dev” . Once this is done. Configure  Eclipse the location of your Python installation. Go to  Window → Preference →Pydev → Interpreters ->Python Interpreter menu. Click New.Enter Interpreter name and the Executable which is the locat...

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....

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...

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 ...

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 ,