July 25, 2011

Working on New Window

July 25, 2011 2
Working on New Window

Below example is to:
  • open the new window by clicking on one link in Main window, 
  • performing some operations in pop up window,
  • then close the pop up window,
  • and operate some function in main window again.

Program:

package one;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

public class Newwindowselenium extends SeleneseTestCase {
public SeleniumServer ss;
@Before
public void setUp() throws Exception {
ss=new SeleniumServer();
ss.start();
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.bitmotif.com/");
selenium.start();
}

@Test
public void testNewwindowselenium() throws Exception {
// open the URL http://www.bitmotif.com/test-page-for-selenium-remote-control/
selenium.open("/test-page-for-selenium-remote-control/");
// Maximizing the main window
selenium.windowMaximize();
// Click on the link This link opens a popup
selenium.click("link=This link opens a popup");
selenium.waitForPopUp("popup", "30000");
// Select the popup window 
selenium.selectWindow("name=popup");
// Click the link About on popup window 
selenium.click("link=About");
selenium.waitForPageToLoad("30000");
// Close the popup window 
selenium.close();
// back to the main window
selenium.selectWindow("null");
// Click on the link This link goes to another page
selenium.click("link=This link goes to another page");
selenium.waitForPageToLoad("30000");
Thread.sleep(10000);
}

@After
public void tearDown() throws Exception {
selenium.stop();
ss.stop();
}
}

July 4, 2011

Selenium 2.0 Sample program

July 04, 2011 1
Selenium 2.0 Sample program
Here is my first post..related to Selenium 2.0 ...

This script is to search for "selenium"  on google...

Below is code with comments..


package setup;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import com.thoughtworks.selenium.Selenium;

public class Default {

WebDriver driver;
Selenium selenium;

@BeforeMethod
public void startSelenium() {
//driver = new FirefoxDriver();  //--To run tests on FF
//Internet Explorer Driver --to Run test in IE
driver = new InternetExplorerDriver();
//driver = new ChromeDriver(); //Chrome Driver -- to run tests in google Chrome
/*Below command is optional if we want to use Selenium commands 
instead of selenium2 we have to declare this*/
//selenium = new WebDriverBackedSelenium(driver, "http://www.pdfonline.com/");
}

@AfterMethod
public void stopSelenium() {
//Closing the Driver
driver.close();
}

@Test
public void testAlert() throws Exception {
//Open Home Page
driver.get("http://www.google.com");
//Enter text in search box
driver.findElement(By.name("q")).sendKeys("selenium");
Thread.sleep(1000);
//Click Search button
driver.findElement(By.name("btnG")).click();
Thread.sleep(10000);


}

}

June 23, 2011

Make Selenium RC run on FF 5

June 23, 2011 19
Make Selenium RC run on FF 5
After upgrading from FF 3.6 to FF4 or 5...your selenium RC scripts  not running on FF.?


Here is the solution for that...

You need to do a simple thing..you have to Upgrade the old selenium-server file....to selenium-server-standalone-2.0rc3.

Here is the new server file New Selenium Server Jar File

Then replace the old file with new server file in eclipse..then restart your eclipse...Now your old scripts will run in FF4 or FF5.


June 22, 2011

Installing Selenium IDE old version(1.0.10 or 1.0.11) on Mozilla Firefox 4 or 5

June 22, 2011 1
Installing Selenium IDE old version(1.0.10 or 1.0.11) on Mozilla Firefox 4 or 5
Installing Selenium IDE old version(1.0.10 or 1.0.11) on Mozilla Firefox 4 or 5


If you want to install IDE 1.0.10 version on FF 4 or 5 it will not allow you to install...


You will get a message not compatible..to avoid that  we need to follow the below steps..


Installing selenium is simple, all you need is to install Selenium IDE addon to Mozilla Firefox.Download FF latest version(5.0).


If you want to install Selenium IDE 1.0.10 on Mozilla 4 or 5 you will need one extra steep. You will have to install compatibility addon to Firefox 4 or 5.
Can be downloaded from Mozilla Firefox Compatibility addon


Download Selenium IDE from Selenium IDE 1.0.10 and instal it on FF. Now F 4 or 5 will support IDE 1.0.10.



Give a try.....

Installing Selenium IDE on Mozilla Firefox 5

June 22, 2011 5
Installing Selenium IDE on Mozilla Firefox 5
Installing selenium is simple, all you need is to install Selenium IDE addon to Mozilla Firefox.Download FF latest version(5.0).


If you want to install Selenium IDE on Mozilla 5 you will need one extra steep. You will have to install compatibility addon to Firefox 5.
Can be downloaded from Mozilla Firefox Compatibility addon



Download Selenium IDE from Selenium site and the version is 1.0.10...


If you want to install 1.0.12  then no need of this comparability add on--


IDE version 1.0.12 will support FF5.

June 13, 2011

Selenium IDE v1.0.11 NOT Support Changing Formats

June 13, 2011 4

Selenium IDE V1.0.11:

It is not supporting Changing formats option...

Format option is Grayed out in Version 1.0.11...

How to Enable it or any alternative to convert the HTML code to desired format..

How to Enable format Option...

Open the Options dialog and turn on the Enable experimental features option. 
Once you turn on the experimental features, you should be able to get formats working again. The Format menu item in the Options menu will no longer be greyed out.
Format


Actually Selenium Experts are not recommending to enable this feature, because it is still under development.  

Alternative way:

Recommended way is to convert your tests to another language is to use the export feature of Selenium IDE.
Export Test Case As menu item in the File menu.


Hope it is useful...

June 1, 2011

Debugging Tests in Selenium IDE

June 01, 2011 0
Debugging Tests in Selenium IDE
Below are the methods or ways of Debugging your selenium IDE scripts..

Selenium IDE reports failures in the log console, and failed test cases within the suite are shown in red.
The failing test cases and commands are highlighted in red, so it’s easy to see what failed, but quite often it can be difficult to understand why it failed. This information is all in the log, but if you’ve run more than just a couple of tests then it will be difficult to match up the failing commands to the errors in the log.

There are a few ways to debug these failures and work out if your application under test has bugs, or perhaps your tests require some changes

Execute Individual Command:


When you double-click a command in Selenium IDE it will be executed – this is very handy when first writing your tests. You could use this to step through each command in each test case until you find a failure, and investigate from there.

Custom Log Messages:

There’s a command in Selenium IDE named echo and this will basically repeat whatever you type into the log when the test is executed. You could use this to output a message associated with an expected failure, and then find this in the log. You do still have to scroll through the log to look for your messages though.

Slow Down:
You can use the speed slider to slow down how fast your test commands are executed. This can be helpful as you can watch the application under test while your tests are running and see any obvious issues that your tests are failing on. You can also use this in combination with executing commands manually by pausing your tests.

Pause, Break and Step:

You can pause your test at any time, either by clicking the Pause icon in the toolbar or by setting breakpoints. Set a breakpoint by right-clicking on a command you want Selenium IDE to pause before executing, and selecting ‘Toggle Breakpoint’ from the context-menu. You will see a small pause icon appear to the left of your command.
When Selenium IDE is paused, the Step icon becomes available. You can use this to execute one command at a time, which can be very useful when approaching a failure or working through a number of verification failures. If you have set multiple breakpoints then you can click the Resume icon to continue executing your tests and stop at the next breakpoint.

Set Start Point:

If you have a really long test and it’s failing towards the end, then you can set a custom start point so that you don’t have to run the entire test when you’re investigating the failure. For example, your test might register a new user, log in, and then fail on the welcome page. You could simply navigate to the welcome page yourself and set your test to start from there. To set a start point simply right click on the first command you want Selenium IDE to execute and click ‘Set / Clear Start Point’. You will see a small play icon appear to the left of your command.

There are many ways that Selenium IDE can assist you in investigating failures and debugging your tests.

May 24, 2011

Selenium 2.0

May 24, 2011 1
Selenium 2.0
This is my First post on Selenium 2.0 ....

Yesterday i downloaded Selenium 2.0 and configured setup in Eclipse...

Great news is i am able to run my first program using Juint...from now on words i will try to run my tests using TestNG and WebDriver..........

i will keep posted...

May 23, 2011

Installing Selenium IDE on Mozilla Firefox 4

May 23, 2011 36
Installing Selenium IDE on Mozilla Firefox 4



Installing selenium is simple, all you need is to install Selenium IDE addon to Mozilla Firefox.


Download Selenium IDE from Selenium site and the latest version is 1.0.10
Download FF latest version.


If you want to install Selenium IDE on Mozilla 4 you will need one extra steep. You will have to install compatibility addon to Firefox 4.
Can be downloaded from Mozilla Firefox Compatibility addon


Download that add on and install in FF....Then Selenium IDE will support...FF 4.0.1.

May 21, 2011

Setting up Selenium RC & TestNG using Eclipse - 1

May 21, 2011 7
I found that it is not easy for the beginners to setup Selenium RC and run the GoogleTest.java example after downloading it from www.openqa.org . The purpose of this post is to help beginners (new users to Selenium RC) help setting up Selenium RC with TestNG using Eclipse.


You need eclipse and TestNg Jar files..


Below are the steps to SetUp TestNG in eclipse.


Step1:


Open Eclipse.
Click on Help form Menubar  and select "Install new software".


Step2:


A new window will be opened. Click Add button.
 A new window is opened. and Enter Name as TESTNG and enter site "http://beust.com/eclipse"








Step3:
Select TestNG and Click Next

Step4:

In the next step click finish




Thats it You installed TESTNG in eclipse...

to verify that you need to click on Project -->new -->Other--?>Yoou can see TESTNG foler and expand that folder you cna see TESTNG Class..

See below screen shot..



Then go to second part of the post....it is post regarding 

Setting up Selenium RC & TestNG using Eclipse-II




May 19, 2011

Working with Multiple windows

May 19, 2011 1
Working with Multiple windows
I saw many posts on identifying window Name, ID and Title or Attribute....but all are giving Syntax...We can find that syntax in Selenium document. In this post, I would like to give an example how to identify window Name, ID and Title or Attribute...


Below is the code is to identify the new window....By using TITLE 


package test;


import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;


public class NewWindow extends SeleneseTestCase {
public SeleniumServer ss;
@Before
public void setUp() throws Exception {
ss= new SeleniumServer();
ss.start();
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.truepanel.com/");
selenium.start();
}


@Test
public void testNewWindow() throws Exception {
selenium.open("/");
   selenium.windowMaximize();
   selenium.setSpeed("2000");
   selenium.click("//div[@id='right']/div[2]/a[1]");
   selenium.setSpeed("2000");
   //Click on Facebook icon
   selenium.click("//div[@id='right']/div[2]/a[2]");
   selenium.setSpeed("2000");
   //Click on Linkedin icon
   selenium.click("//div[@id='right']/div[2]/a[3]");
   selenium.setSpeed("2000");
      String[] winNames = selenium.getAllWindowTitles();
 //All window names should be displayed in console
      for (int i = 0; i < winNames.length; i++) 
   {
    System.out.println("Window Titles are "+winNames[i]);
}
             
   /*selenium.selectWindow("Twitter");
   verifyEquals("Truepanel (Truepanel) on Twitter", selenium.getTitle());*/
   //Selects the new window with Title Truepanel | Facebook
   selenium.selectWindow("TruePanel | Facebook");
   selenium.setSpeed("2000");
   selenium.windowFocus();
   selenium.setSpeed("2000");
   selenium.windowMaximize();
   selenium.setSpeed("2000");
   if(selenium.isElementPresent("//div[@id='globalContainer']/div[2]/div/a/span"))
   {
    selenium.click("//div[@id='globalContainer']/div[2]/div/a/span");
selenium.waitForPageToLoad("30000");
selenium.type("firstname", "test");
selenium.type("lastname", "test");
selenium.type("reg_email__", "tets");
selenium.type("reg_email_confirmation__", "test");
selenium.selectWindow("null");
       selenium.windowFocus();
       verifyEquals("Welcome to Truepanel | Online Video Focus Groups", selenium.getTitle());
       selenium.click("//div[@id='navBtns']/a[2]");
selenium.waitForPageToLoad("30000");
       Thread.sleep(1000);
   }
   
     else
     {
    //this command will select the parent window
       selenium.selectWindow("null");
       selenium.windowFocus();
       verifyEquals("Welcome to Truepanel | Online Video Focus Groups", selenium.getTitle());
       Thread.sleep(1000);
   }
}
@After
public void tearDown() throws Exception {
selenium.stop();
ss.stop();
}
}