У меня есть веб -страница с несколькими элементами, которые будут протестированы.
они более 100, и я не мог написать 100 кода для тестирования одного элемента.
можно ли использовать корпус Switch для проверки элемента, который я хочу, и не все. 100 тестов для выполнения, я хочу использовать только один код. < /P>
Спасибо < /p>
//TEST1
try {
driver.findElement(By.xpath(CmpList._google)).isDisplayed();
System.out.println("Google Tab exists");
driver.findElement(By.xpath(CmpList._google)).click();
} catch (NoSuchElementException e) {
System.out.println("TEST FAILED--Google Tab element does not exist");
} finally {
System.out.println("Continue");
}
//TEST2
try {
driver.findElement(By.xpath(CmpList._radio)).isDisplayed();
System.out.println("Radio Tab element exists");
driver.findElement(By.xpath(CmpList._radio)).click();
} catch (NoSuchElementException e) {
System.out.println("TEST FAILED--Radio Tab element does not exist");
} finally {
System.out.println("Continue");
}
//TEST3
try {
driver.findElement(By.xpath(CmpList._yahoo)).isDisplayed();
System.out.println("Google Tab exists");
driver.findElement(By.xpath(CmpList._yahoo)).click();
} catch (NoSuchElementException e) {
System.out.println("TEST FAILED--Yahoo Tab element does not exist");
} finally {
System.out.println("Continue");
}
Подробнее здесь: https://stackoverflow.com/questions/252 ... -in-a-page