如何打印下方和上方的文本通过:在硒的控制台区域

How to print text below and above Passed: in the console area in selenium

我有三个@test 方法来添加、更新和删除网页中的记录,执行完成后我正在寻找类似下面的输出,我在哪里可以使用 sisout 打印突出显示的消息,我是运行 我在 TestNG 中的代码。

   @Test(priority=2)
  void updateAddressBook() {
try{
driver.findElement(By.id("radio1")).click();
driver.findElement(By.id("edit")).click();
driver.findElement(By.id("company")).clear();
Thread.sleep(3000);
driver.findElement(By.id("company")).sendKeys("Vuram");
driver.findElement(By.id("add")).click();
Log.info("Validate company name is updated for user 2");
Reporter.log("Company name sucessfully updated for user 2");
passCount++;
}  catch (Error e) {
    verificationErrors.append("Cannot provide the input please stick to the UI constraints5.\n");
} catch(Exception e){
    verificationErrors.append("Cannot provide the input please stick to the UI constraints6.\n");
}

try {
    String x = driver.findElement(By.id("result")).getText();
    if(x.contains("Vuram"));
    {  
        passCount++;
    }
 } catch (Error e) {
    verificationErrors.append("Element by id 'td' not found.\n");
  } catch (Exception e) {
    verificationErrors.append("Element by id 'td' not found.\n");
  }
}

这就是您要找的解决方案,只需实施示例演示即可:

System.out.println();对于控制台日志

@Test(description = "") 测试说明

public class demo {

    @Test(description = "This is description of Test Case")
    public void TestDemo() {

        System.out.println("****************************");
        System.out.println("Hello World");
        System.out.println("****************************");
    }

}