2016-10-31 74 views
-1

我正在Eclipse中使用Selenium Webdriver。我想它打開通過Web頁面列表循環硒

http://www.sample.com/catalog?product_id="0001" 

填充字段和檢查徑向按鈕,然後關閉,然後環路開路

http://www.sample.com/catalog?product_id="0002"` 

,並執行相同的操作。我希望它循環,直到達到9990

System.setProperty("webdriver.firefox.marionette","/Users/Downloads/geckodriver"); 
WebDriver driver; 
driver = new FirefoxDriver(); 
String base = ("http://www.sample.com/catalog?product_id="0001"); 
+0

在TestNg/Junit中搜索數據驅動的測試。這裏是TestNg的一個例子[鏈接](http://www.software-testing-tutorials-automation.com/2014/05/webdriver-test-data-driven-testing.html) – Knu8

+1

那麼你試圖完成什麼循環?請發佈您的代碼。 – JeffC

回答

0

代碼片段:

for(int i = 1; i <= 9990; i++){ 
     String base = "http://www.sample.com/catalog?product_id=" + String.format("%04d", i); 
     driver.get(base); 
     //do your stuff here 
    } 

上面的代碼片段將建立您的網址,你想和所需的頁面上的土地。