0

I'm creating a application with WebDriver API for make non regression tests.

At a moment, I have to find an element (fic) on my computer (with the Windows's navigator), and i can't (or I just fail :P) do this with WebDriver.

So I'm searching for and I've find awt.Robot . But this robot just click on a [px,px] position.. How can I say 'Click on the search bar, click on the element with the name "A", click on the "OK" button ?' (All of these elements are Windows's elements.) Thank you for help !

pikameuh
  • 149
  • 1
  • 1
  • 12
  • Webdriver can't do this, as you've found, because it can only interact with web-browser elements, as in those elements rendered within a web-browser. Using the `Robot()` class is the correct way to go but you'll have to do it the hard way and provide the pixel locations of where you want to click. – Mark Rowlands May 21 '14 at 09:14
  • Ok I've find a way, THX !! [here](http://stackoverflow.com/questions/6091531/how-to-get-the-x-and-y-of-a-program-window-in-java) But now how i can press '\' for make a path? When I do : "robot.keyPress(KeyEvent.VK_BACK_SLASH); " that make a error : "java.lang.IllegalArgumentException: Invalid key code", but woth the code "robot.keyPress(KeyEvent.VK_COLON); " it works.. WHY ? – pikameuh May 21 '14 at 10:16

1 Answers1

0

The solution (for me) is to use this exemple to get the position+dimension of the window by its name.

int[0] = X
int[1] = Y
int[2] = width
int[3] = height

In a second time, I use the awt.Robot with moveMouse() at the good position and click() or place the good characters.

For the '/' slash, I use :

robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_COLON);
robot.keyRelease(KeyEvent.VK_COLON);
robot.keyRelease(KeyEvent.VK_SHIFT);

I hope this helps someone.

Community
  • 1
  • 1
pikameuh
  • 149
  • 1
  • 1
  • 12