org.openqa.selenium.htmlunit.remote.HtmlUnitWebElementToJsonConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of htmlunit-remote Show documentation
Show all versions of htmlunit-remote Show documentation
This is the remote wrapper for HtmlUnitDriver
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);
}
}