int count = 0; String [] CRI = { "选择角色。", " 0 - ABCD", " 1 - EFMK", " 2 - XYZV"};
blogs_path
附件CRI [\] \ [1 \] />
答案 0 :(得分:0)
我会使用Select
类来处理任何SELECT
标记。请尝试下面的代码。
String[] expectedIssues = { "Select Client Reporting Issue...", "0 - ABCD", "1 - EFMK", "2 - XYZV" };
List<WebElement> options = new Select(driver.findElement(By.id("ClientReportingIssue"))).getOptions();
if (expectedIssues.length != options.size())
{
// count of issues did NOT match
System.out.println(
"FAIL: CRI issues count failed. Expected: <" + expectedIssues.length + "> but there were <" + options.size() + ">");
}
else
{
// count of issues matched
System.out.println("Total Role: " + options.size());
boolean pass = true;
for (int i = 0; i < options.size(); i++)
{
if (!options.get(i).getText().equals(expectedIssues[i]))
{
pass = false;
continue; // once it fails, quit the for loop
}
}
if (pass)
{
System.out.println("PASS: CRI Information Matched");
}
else
{
System.out.println("FAIL: CRI Information NOT Matched");
}
}