headerBar(msnlogo) 和 PageTitle

上一篇 / 下一篇  2012-04-27 18:15:22 / 个人分类:TestNG/Ant/Eclipse/Java

package ENSG;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.*;
import static org.testng.Assert.*;
public class PageTitle {
 @Test(groups = { "funtest","pagetitle"}) 
  public void Pagetitle() {
  WebDriver driver = new FirefoxDriver();
  //WebDriver driver = new HtmlUnitDriver();
  //use htmlunit is too quick and get about:blank
        driver.get("http://xin.msn.com/default.aspx");        
       
        String title = "xinmsn | Singapore - Hotmail, Messenger, Free online News, Video, Photos, Movies, Entertainment, Sport & more..";
        assertEquals(title, driver.getTitle());
       
        System.out.println("page title is right, pls go ahead......");
       
        String expectPagetitle = driver.getTitle();
        System.out.println("current page title:" + "\n"+ expectPagetitle);
       
        String currentUrl = driver.getCurrentUrl();
        System.out.println("current page url:" + "\n"+ currentUrl);       
       
        driver.close();
  }
}
 
 
public class headerBar {
 
@Test(groups = { "funtest","headerbar","msnlogo"})   
public void msnlogo() {
  WebDriver driver = new FirefoxDriver();
  //WebDriver driver = new HtmlUnitDriver();
  //use htmlunit:Unable to locate a node using //img[@alt='msn']
        driver.get("http://xin.msn.com/?lang=en-sg");
        String url=driver.findElement(By.xpath("//img[@alt='msn']")).getAttribute("src");
        String width=driver.findElement(By.xpath("//img[@alt='msn']")).getAttribute("width");
        String height=driver.findElement(By.xpath("//img[@alt='msn']")).getAttribute("height");
        assertEquals("147",width);
        assertEquals("51",height);
        //fun assertEquals(String message, Object expected, Object actual)
        //if(width.equals("147")){
        //if(height.equals("51")){
        System.out.println("msn logo path is: " + url);
       // }
       // }
        driver.close();
  }

TAG:

MillionRoses 引用 删除 dian106106   /   2012-04-28 11:32:15
@Test(groups = { "funtest","headerbar","msnlogo"})   
        public void msnlogo() {
          WebDriver driver = new FirefoxDriver();
          //WebDriver driver = new HtmlUnitDriver();
          //use htmlunit:Unable to locate a node using //img[@alt='msn']
                driver.get("http://xin.msn.com/?lang=en-sg");
                String url=driver.findElement(By.xpath("//img[@alt='msn']")).getAttribute("src");               
                String suburl=url.substring(url.length()-4,url.length());
                String width=driver.findElement(By.xpath("//img[@alt='msn']")).getAttribute("width");
                String height=driver.findElement(By.xpath("//img[@alt='msn']")).getAttribute("height");
                assertEquals("147",width);
                assertEquals("51",height);
                assertEquals(".gif",suburl);
                driver.close();
          }
MillionRoses 引用 删除 dian106106   /   2012-04-27 18:20:58
@Test(groups = { "funtest","headerbar","msnlogo"})  

补上一个groups
 

评分:0

我来说两句

日历

« 2024-05-13  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 74672
  • 日志数: 80
  • 建立时间: 2012-04-12
  • 更新时间: 2013-05-21

RSS订阅

Open Toolbar