I have written framework using object design pattern. To make it better I am also using .
Example:

BasePage.

@FindBy(xpath= FinalLocators.userName)
WebElement uname;

@FindBy(xpath= FinalLocators.userpass)
WebElement userpwd;

sendkeys.uname("johndoe");
sendkeys.userpwd("kitty");

FinalLocators.java

public static final String userName=//input[text()='username']
public static final String userpass=//input[text()='password']

Now, I want loggers () to give me:

Element uname not found. I want the WebElement name to be in logs not the xpath declared in FinalLocators.

Edit:
In non PageFactory projects it is written something like this:

public void sendData(String xpathKey){
    try{            
    driver.findElement(By.xpath(OR.getProperty(xpathKey))).sendKeys("abc");
    logger.info("Found "+xpathKey);
    }catch(Exception e){
    logger.info("wait started for "+xpathKey);

            }

}

But in PageFactory based framework how to such ?



Source link https://sqa.stackexchange.com/questions/20033/java-selenium-log4j-how-to-write-generic-function-for--in-pagefactor

LEAVE A REPLY

Please enter your comment!
Please enter your name here