driver.findElement(By.name("RNSCategoryFilter1$btnsubmit")).click();对于上述步骤,如何在控制台中写入测试通过/失败结果?例如,对于下面的代码,我有写if...else..标识通过或失败结果的条件。同样,我想为上面的代码写通过和失败的条件。
List<WebElement> urls = driver.findElement(By.id("DataNewsFeeds")).findElements(By.tagName("a"));
for (WebElement urlclick : urls) {
if(urlclick.getText().contains(toolURL))
{
driver.navigate().to(toolURL);
url = true;
break;
}
}
if(url)
{
System.out.println("TC-4 Passed: '" +toolURL+ "' Clicked");
}
else
System.out.println("TC-4 Failed: '" +toolURL+ "' not found");发布于 2020-03-02 16:54:30
假设在按钮上点击操作后,button消失了,或者页面上发生了一些事情,你可以这样做-
boolean clickOperationsAssert = driver.findElement(By.name("locator_of_element_if_selected_after_click_operation")).isSelected();
driver.findElement(By.name("locator_of_new_element_after_click_on_button")).isDisplayed();
driver.findElement(By.name("locator_of element_enabled_after_click_operation")).isEnabled();isSelected()、isDisplayed()、isEnabled()方法将返回布尔值,您可以断言。
if(clickOperationsAssert){
System.out.println("TC-5 Passed: '" +toolbutton+ "' Clicked");
}
else{
System.out.println("TC-5 Passed: '" +toolbutton+ "' not found or not able to click");
}https://stackoverflow.com/questions/60474342
复制相似问题