Code snippet ready-made...

To get web element properties:


I am assuming you have already driver and element initialized in hand, then the following code is used to read the element properties 

/**
 * Return properties list of an element
 */
public static Object getElementProperties(WebElement element){
    Object object = ((JavascriptExecutor)driver).executeScript("var item{};  " + 
                                 " for (index = 0; index < argument[0].attributes.length(); ++index)  { " +
                                 " items[arguments[0].attributes[index].name = arguments[0].  " +                                                              " attributes[index]. value}; return items; ", element)
    return object;
}

No comments:

Post a Comment