How to edit and print the specification of webelement using Log4j?

jamal :

In my testing framework I've got a method called 'isElementDisplayed'.

public boolean isElementDisplayed(WebElement element) {
    try {
        logger.info(element);
        return element.isDisplayed();
    } catch (NoSuchElementException e) {
        return false;
    }
}

After execute logger write to file specification of webelement like:

[[ChromeDriver: chrome on XP (hash)] -> id: idofelement]

How can I make it shorter just like:

[id: idofelement]

It there any possibility to cut unnecessary beginning?

DebanjanB :

As per the discussion Values returned by webdrivers within the Browser Specific Implementation section:

A small test was carried out with the Search Box of Google Home Page i.e. https://www.google.co.in with ChromeDriver and here was the observation:

  • ChromeDriver - OSS :

    [[ChromeDriver: chrome on XP (0d24fd038bde751b1e411711271c3e69)] -> name: q]
    [[ChromeDriver: chrome on XP (0d24fd038bde751b1e411711271c3e69)] -> name: q]
    

So as you can observe from the field details of the concerned value field returned is in similar pattern and till the WebDriver variant passes the correct reference to user and is not configurable/editable.

Further, if you want to edit (and then print) the value you have to write a sparate method for regex handling.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=133255&siteId=1