2017-06-06 55 views
1

我將如何通過下拉列表中的9個選擇進行循環......比如說它有9個不同的值,我將如何使用select來使它們全部通過?通過下拉webdriver循環

例。值分別是 紅 藍綠色 紫

到目前爲止,我有

for (int i=0; i<4; i++){ 

     WebElement ClubDropDown = driver.findElement(By.id("tenantList")); 

     Select CDropdown = new Select(ClubDropDown); 

// This is the part I'm stuck on how to make it loop through the drop downs and preform the defined public void cases 


     OpenMp(); // This is one of my public void test cases 
    } 
+0

您能否考慮共享相關的HTML DOM?請提及您的手動測試步驟,以便我們可以更好地指導您。謝謝 – DebanjanB

回答

0

在Java8

Select cDropdown = new Select(ClubDropDown); 
cDropdown.getOptions().forEach(el -> { 
       //do something 
}); 

附:從小寫字母開始變量名稱ClubDropDown -> clubDropDown