OnlyTheStrongSurvive

seleniumTest

上一篇 / 下一篇  2011-10-20 17:56:35 / 个人分类:自动化

package com;


import static org.junit.Assert.assertEquals;
import javax.servlet.http.HttpServletRequest;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class seleniumTest{
    WebDriver driver = new FirefoxDriver();
    String ss="selenium";
    public HttpServletRequest request;
    @Before
    public void setUp() throws Exception {
        //driver.get("http://www.baidu.com");
        driver.navigate().to("http://www.baidu.com");
    }
    @Test
    public void seleniumTest1() throws Exception {
        driver.findElement(By.id("kw")).click();
        driver.findElement(By.id("kw")).clear();
        driver.findElement(By.id("kw")).sendKeys("selenium");
    /*    (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("chees!");
            }
        });*/
        driver.findElement(By.id("su")).click();
        System.out.println(driver.getTitle());
        System.out.println(driver.findElement(By.xpath("//html/body/div/div/div/div[2]/table[2]/tbody/tr/td/h3/a/em")).getText());    
        //System.out.println(driver.findElement(By.id("1")).getText());
        
       
        assertEquals(ss,driver.findElement(By.xpath("//html/body/div/div/div/div[2]/table[2]/tbody/tr/td/h3/a/em")).getText());
    }
    @After
    public void tearDown() throws Exception {
        driver.quit();
    }
}
 

TAG:

 

评分:0

我来说两句

Open Toolbar