I am trying to click a button with no id, only class. Because of that, I have had to recue the element by xpath, having an Element object, which no click method. Does anyone know some strategy to achive clicking this Element?
Here the code where I am getting the Element:
WebView wv = new WebView();
WebEngine we = wv.getEngine();
we.load("https://www.milanuncios.com/");
we.getLoadWorker().stateProperty().addListener((observable, oldState, newState) -> {
if (newState == Worker.State.SUCCEEDED) {
Document doc = we.getDocument();
Element inputField = null;
try {
inputField =
(Element) XPathFactory.newInstance().newXPath().evaluate("//*[@class=\"ma-NavigationTopNav-mainActions-desktop\"]",
doc, XPathConstants.NODE);
} catch (XPathExpressionException e) {
e.printStackTrace();
}
if (inputField != null) {
LOGGER.log(Level.INFO, "DENTRO "+inputField);
}
}
});
processPaneField.getChildren().add(wv);