沒有代碼就沒有代碼很難幫你。我會盡力勾勒出一點幫助我怎麼處理這個:
public void chooseProduct(String product){
List<WebElement> Options = new ArrayList<WebElement>();
productChoooser = driver.findElement(By.id("id_of_the_selectbox"));
productChoooser.click();
Select select = new Select(productChoooser);
Options = select.getOptions();
for (WebElement option:Options){
if(option.getText().equals(product)){
option.click();
}
}
上面的代碼從下拉一個項目。您可以輕鬆地修改它bymodyfying的如果聲明在此,說:
boolean foundIt = false;
for (WebElement option:Options){
if(option.getText().equals(product)){
System.out.println("The product " + product + "was found in the drop down list");
foundIt = true;
}
}
if (!foundit){
System.out.println("The product " + product + "was NOT found in the drop down list");
}
}
請跟我重新檢查了,我直接寫代碼的答案窗口
可以ü分享您的代碼和輸出? – Amey