Friday, January 21, 2011

Verify value in drop down list.

package test;

import com.thoughtworks.selenium.*;

import org.openqa.selenium.server.*;
import org.testng.annotations.*;


public class Dropdownall {
public Selenium selenium;
public SeleniumServer seleniumserver;

  @BeforeClass
  public void setUp() throws Exception {
RemoteControlConfiguration rc = new RemoteControlConfiguration();
seleniumserver = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://");
seleniumserver.start();
selenium.start();
}

@Test
public void testDropdownall()throws Exception {
selenium.open("http://www.google.com");
selenium.windowMaximize();
selenium.click("link=Advanced Search");
selenium.waitForPageToLoad("50000");
//Verifying Element is Present or not here i used xpath to find that
if(selenium.isElementPresent("//select[@name='num']/option[contains(text(),'50 results')]"))
{
System.out.println("ys");
}

}
   
 @AfterClass
 public void tearDown()throws Exception {
selenium.stop();
seleniumserver.stop();
 
 }
 }


No comments:

Post a Comment