2016-10-31 71 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 
    } 

上面的代码片段将建立您的网址,你想和所需的页面上的土地。