-1

How do I simulate a click with coordinates on HtmlPage then get the result a HtmlPage?

I want to click a button without an id or a name

I'm using the library com.gargoylesoftware.htmlunit

NaviRamyle
  • 3,967
  • 1
  • 31
  • 49

2 Answers2

0

not sure about specific system or browser settings, but in general you can do this by following:

import java.awt.event.*;
import java.awt.Robot;
public class test {
int xparam=50;
int yparam=100;
 public static void main(String args[]) {
  Robot mybot = null;
  try {
   mybot = new Robot();
  } catch (Exception failed) {
   System.err.println("Failed instant. Robot: " + failed);
  }
  int maske = InputEvent.BUTTON1_DOWN_MASK;

  mybot.mouseMove(xparam,yparam);
  mybot.mousePress(maske);
  mybot.mouseRelease(maske);
 }
}

For a smoother solution take a look at this ;

Community
  • 1
  • 1
LPH
  • 1,275
  • 9
  • 16
0

No,You can't click button with coordinates(X,Y). Please specify the element other attributes because it can be click with help of other attribute

Kick
  • 4,823
  • 3
  • 22
  • 29