我正在使用selenium appium来测试移动应用程序。我的一个测试是注册用户实际上已经失败了,但它显示为在我的eclipse控制台中传递。
@Test
public void registerNewUserFromSignInPage() {
try {
String app_package_name = "com.xyz.abc:id/";
By signInBtn = By.id(app_package_name + "btn_sign_in");
System.out.println("Clicking on Sign in button");
driver.findElement(signInBtn).click();
By registerFromSignInPage = By.id(app_package_name + "btn_signuptrial");
System.out.println("Register from Sign in page");
driver.findElement(registerFromSignInPage).click();
//Launch Page
By registerBtn = By.id(app_package_name + "btn_register");
System.out.println("Clicking on register button");
driver.findElement(registerBtn).click();
//Register screen
By btn_signup_email = By.id(app_package_name + "btn_signup_email");
System.out.println("Clicking on signup email button");
driver.findElement(btn_signup_email).click();
//Signup Screen
By fullname = By.id(app_package_name + "et_name");
System.out.println("Typing Full name");
driver.findElement(fullname).sendKeys("Test QA");
By email = By.id(app_package_name + "et_email");
System.out.println("Typing Mail ID");
driver.findElement(email).sendKeys("testqa@test.com");
By passwrd = By.id(app_package_name + "et_password");
System.out.println("Typing password");
driver.findElement(passwrd).sendKeys("samplepassword");
By submitBtn = By.id(app_package_name + "btn_signup");
System.out.println("Clicking on Submit button");
driver.findElement(submitBtn).click();
Thread.sleep(3000);
By successMessage = By.id(app_package_name + "tv_success_text");
boolean result = driver.findElement(successMessage).isDisplayed();
System.out.println("The success message is displayed: " + result);
String text = driver.findElement(successMessage).getText();
System.out.println("The success message text is : " + text);
By btnTC = By.id(app_package_name + "btn_tc");
By nextBtn = By.id(app_package_name + "btn_next");
By selectOption = By.id(app_package_name + "cb_none");
By selectGender = By.id(app_package_name + "btn_male");
By selectHeight = By.id(app_package_name + "et_height ");
By selectWeight = By.id(app_package_name + "et_weight");
By selectEthnicity = By.id(app_package_name + "et_ethinicity");
By selectEthnicityOption = By.id(app_package_name + "select_dialog_listview");
By submitDetails = By.id(app_package_name + "btn_submit");
By startApp = By.id(app_package_name + "btn_startapp");
By firstEntry = By.id(app_package_name + "fabMain");
By logFood = By.id(app_package_name + "fab_food");
By gotTutorial = By.id(app_package_name + "btn_dialog_tutorial_ok");
//signin page
By username = By.id(app_package_name + "et_email");
By password = By.id(app_package_name + "et_password");
By signIn = By.id(app_package_name + "btn_sign_in");
By register = By.id(app_package_name + "btn_signuptrial");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
在控制台中,它显示了预期的错误: -
使用给定搜索无法在页面上找到元素 参数。 (警告:服务器未提供任何堆栈跟踪 信息)命令持续时间或超时:41毫秒
但是,测试用例显示为: - PASSED : registerNewUserFromSignInPage
答案 0 :(得分:0)
因为你在这里没有断言。通常,不要试图捕获测试用例中的错误。如果测试由于任何错误而失败。让它失败。对于记录,除非您有断言,否则测试将保持通过。