Showing posts with label Selenium RC. Show all posts
Showing posts with label Selenium RC. Show all posts

Tuesday, June 18, 2013

Start working on Selenium RC

import
com.thoughtworks.selenium.DefaultSelenium;
public
class Flight {
public static DefaultSelenium selenium = new DefaultSelenium("localhost",4444,"*firefox","http://");
public static String openUrl() throws Exception
{
selenium.start();
selenium.setTimeout("30000");
selenium.windowMaximize();
selenium.open("http://www.harleysvillegroup.com/");
selenium.waitForPageToLoad("10000");
//selenium.captureScreenshot("C:\\skhan.png");
selenium.click("name=file_1");
selenium.waitForPageToLoad("10000");
Thread.sleep(5000);
//selenium.type("name=Wizard1$ctl07$HolderInfoControl1$txtPolicy", "BOP00000012345");
//selenium.type("name=Wizard1$ctl07$HolderInfoControl1$txtName", "Skhan");
return "pass";
}
public static void main(String[] args) throws Exception {
openUrl();
}
}

Friday, June 7, 2013

How to display all values from Drop down ?

selenium.getSelectOptions(selectLocator);
Store those values in an array.
String a[]=selenium.getSelectOptions(“name=sel”)

How to select a value from Drop down?

To select a value from Dropdown we need to use the below command.Select an option from a drop-down using an option locator.
Option locators provide different ways of specifying options of an HTML Select element (e.g. for selecting a specific option,  or for
asserting that the selected option satisfies a specification). There are several forms of Select Option Locator.
  label=labelPattern: matches options based on their labels, i.e. the visible text. (This is the default.)
o  label=regexp:^[Oo]ther
Usage:
selenium.select(selectLocator, optionLocator);
selenium.select(“id=abc”,”label=shopping”);

How to Select a Radio button in Selenium RC

To Select a radio button on web page please use the below command.

Check a toggle-button (checkbox/radio)
Parameters:
locator an element locator
Usage:
Selenium.click(“locator”); or Selenium.check(“locator”);
Selenium.click(“id=123”); or Selenium.check(“id=123”);

How to check a check box in Selenium RC

To check a Check box on web page please use the below command.
Check a toggle-button (checkbox/radio)
Parameters:
locator an element locator
Usage:
Selenium.click(“locator”); or Selenium.check(“locator”);
Selenium.click(“id=123”); or Selenium.check(“id=123”);

How to click on button in Selenium RC

To click a Button on web page please use the below command.
Clicks on a link, button, checkbox or radio button. If the click action causes a new page to load (like a link usually does),  call
waitForPageToLoad.
Parameters:
locator an element locator
Usage:
Selenium.click(“locator”);
Selenium.click(“id=123”);

How to click on link in Selenium RC

To click a link on web page please use the below command.

Clicks on a link, button, checkbox or radio button. If the click action causes a new page to load (like a link usually does), call
waitForPageToLoad.
Parameters:
locator an element locator
Usage:
Selenium.click(“locator”);
Selenium.click(“id=123”);

How to type a word in text box in Selenium RC

To type a word in text box or text area we have to use the below command.

Syntax:

Sets the value of an input field, as though you typed it in.  Can also be used to set the value of
combo boxes, check boxes, etc. In these cases, value should be the value of the option selected,
not the visible text.
Parameters:
locator an element locator
value the value to type
Usage:
Selenium.type(“locator”, “value”);
Selenium.type(“id=123”, “selenium”);
For sample script, please go through the script TextBox.java