All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openqa.selenium.htmlunit.remote.HtmlUnitWebElementToJsonConverter Maven / Gradle / Ivy

The newest version!
package org.openqa.selenium.htmlunit.remote;

import java.util.Map;

import org.openqa.selenium.WrapsElement;
import org.openqa.selenium.htmlunit.HtmlUnitWebElement;
import org.openqa.selenium.remote.Dialect;
import org.openqa.selenium.remote.WebElementToJsonConverter;

/**
 * Converts {@link HtmlUnitWebElement} objects, which may be {@link WrapsElement wrapped}, into their
 * JSON representation as defined by the WebDriver wire protocol. This class will recursively
 * convert Lists and Maps to catch nested references.
 *
 * @see 
 *     WebDriver JSON Wire Protocol
 */
public class HtmlUnitWebElementToJsonConverter extends WebElementToJsonConverter {
    @Override
    public Object apply(Object arg) {
        if (arg instanceof HtmlUnitWebElement) {
            return Map.of(Dialect.W3C.getEncodedElementKey(), String.valueOf(((HtmlUnitWebElement) arg).getId()));
        }
        return super.apply(arg);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy