Select some area in a web page using Robot class.
I am using Java+Webdriver 2.25 + Eclipse + Junit + Firefox (Ours is Ubuntu operating system)
In our application, we have one page (we call it Work Convas), and on it, there are 2 fields. These are click-able and can be selected by clicking (these are <TD>s).
I need to EITHER - Ctl+click all these 2 items at once and verify whether or not they have been selected.
OR - Can drag select the area in which these 2 fields exist on the page.
As FF has issues with Keys.CONTROL it is failing when I use Actions class and the Keys.CONTROL/SHIFT.
I spent almost 2 hours doing in different ways (from different forums).
So, I migrated to Robot. My code is
Robot robot = new Robot();
// SET THE MOUSE X Y POSITION
robot.mouseMove(260, 800);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseMove(1060,800);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
But this also not working, any suggestions!!
Re: Select some area in a web page using Robot class.
You're going to have to be more specific than "not working". You should also provide an SSCCE that demonstrates exactly what this code does and how that differs from what you'd expect. As of now we have no idea what you expect that code to do, what it actually does, or even how to run it.
1 Attachment(s)
Re: Select some area in a web page using Robot class.
Sure, here are some details, hope this will make things clear!
Attachment 4426
The above is a page on our application.
On that page, there are 2 fields, and we need to select those two fields by drag the mouse (via code) around those 2 fields.
In that way these will be selected. This is the purpose.
I am not able to select the area (by drag the mouse around those 2 fields) when I used the code above (Robot class)
Re: Select some area in a web page using Robot class.
Which part of this isn't working? Does your code successfully move the mouse? Does it emulate a drag gesture? Have you tested that part by itself? Does your page respond to drag gestures from a human? What exactly is this code doing? You might have to step through it with a debugger to find out.
1 Attachment(s)
Re: Select some area in a web page using Robot class.
Thanks KevinWorkman for your time!
I manually tested and it is working fine!
Attachment 4427
It is moving the mouse coordinates, but not releasing the mouse (so that area can be select, so are the fields inside of that area).
Am I missing the correct coordinates?
Re: Select some area in a web page using Robot class.
I don't really know how your selection mechanism works, so I can't really tell whether you're missing coordinates. Like I said, the best way to test this is to step through it with a debugger. Or you should draw out what's actually happening: where does the mouse start? Where does it end up? Are you sure?
Re: Select some area in a web page using Robot class.
Thanks for your help!
I will debug again once I am at office, I will debug step by step and publish my findings.