import com.thoughtworks.selenium.DefaultSelenium;
public class test {
/**
* @param args
* @throws InterruptedException 
*/
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
 String host = "localhost";  
     int port = 4444;  
     String url = "http://www.taobao.com/go/act/sale/summer2012-yr.php";  
  
     //String keyWordsLocator = "document.getElementById('kw')";     
     String search = "document.getElementById('award_btn')";  
     DefaultSelenium selenium = new DefaultSelenium(host,port,"*firefox D:/Program Files/Mozilla Firefox/firefox.exe",url);  
     selenium.start();  
     selenium.open(url); 
     //selenium.waitForPageToLoad("50000"); 
     selenium.windowMaximize();
     selenium.windowFocus();
     //selenium.waitForPageToLoad("50000"); 
     //selenium.type(keyWordsLocator,"java selenium"); 
     
//      for(int i=0; i<=5; i++){
//      //selenium.waitForPageToLoad("30000"); 
//      selenium.click("award_btn");
//      System.out.println("success1");
//      selenium.refresh();
//      } 
     
     int i = 0;
     
     while(true) {
     if (selenium.isElementPresent("award_btn")){
     selenium.click("award_btn");
     Thread.sleep(2000);
     selenium.refresh();
     //selenium.waitForPageToLoad("10000");
     System.out.println(++i);
     System.out.println("success");
     }
     }
     //selenium.stop();
     //System.out.println("success");
}
}
posted on 2012-07-14 14:29  fishren  阅读(2617)  评论(0编辑  收藏  举报