需要一些例子来说明如何在SeleniumWebDriver中使用TestNG来使用Assertstatements
如何在SeleniumWebDriver中使用下面的断言语句需要一些例子来说明如何在SeleniumWebDriver中使用TestNG来使用Assertstatements,selenium,testng,Selenium,Testng,如何在SeleniumWebDriver中使用下面的断言语句 Assert.AssertTrue(条件,字符串) Assert.AssertFalse(条件输入,字符串) 当条件失败时,请让我知道显示字符串语句的位置(在控制台/报告中) 基本思路如果您想要检查某些内容,并且您知道正确的行为(预期的行为)在条件下是错误的(例如,您已登录并且页面标题不同),那么您可以使用Assert.AssertFalse() 如果预期行为在条件下为真(例如,页面标题相同),请使用Assert.AssertTrue
Assert.AssertFalse()
如果预期行为在条件下为真(例如,页面标题相同),请使用
Assert.AssertTrue()
您将使用asserts来断言某些行为,即断言您的预期结果。
如果断言失败,将停止执行。当assert失败时,AssertionError将与字符串一起抛出,作为其跟踪的一部分。此消息将在控制台和testng报告两个位置都可用
Assert.assertEquals("Your Test Message", driver.findElement(By.className("className")).getText());
Assert.assertEquals("Your Test Message", driver.findElement(By.className("className")).getText());