Я использую POM, используя testng + java + maven. Можем ли мы печатать по имени объекта в журнале или расширении отчета для целей отчетности?Я использую Log4j и extenreports.
Пример: Мой класс commonfunction содержит все действия, выполняемые для тестовых случаев:
public void click(By element) {
WebElement webElement = getElement(element);
try {
Log.info("Clicking on the webelement " + element);
webElement.click();
ExtentTestManager.getTest().info("clicking on the webelement - " + element);
}
catch (NoSuchElementException e) {
Log.error(e.getMessage());
ExtentTestManager.getTest().fail(e);
throw new TestException(String.format("The following element is not clickable: [%s]", element));
}
}
и в моем pageobject class, я объявляю xpath как:
By clearFormButton = By.xpath("//*[@id='createPopulation:j_idt198']");
and in my test step:
commonfunction.click(clearFormButton);
Actual output : Clicking on the webelement By.xpath:
//*[@id='createPopulation:j_idt198']
Expected output : Clicking on the webelement clearFormButton - By.xpath:
//*[@id='createPopulation:j_idt198']