Results 1 to 7 of 7
  1. #1
    vsb
    vsb is offline Member
    Join Date
    Oct 2011
    Posts
    17
    Rep Power
    0

    Default 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!!

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default 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.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    vsb
    vsb is offline Member
    Join Date
    Oct 2011
    Posts
    17
    Rep Power
    0

    Default Re: Select some area in a web page using Robot class.

    Sure, here are some details, hope this will make things clear!

    Select some area in a web page using Robot class.-workconvas.jpg

    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)

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default 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.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    vsb
    vsb is offline Member
    Join Date
    Oct 2011
    Posts
    17
    Rep Power
    0

    Default Re: Select some area in a web page using Robot class.

    Thanks KevinWorkman for your time!

    I manually tested and it is working fine!
    Select some area in a web page using Robot class.-workconvas.jpg
    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?

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default 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?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    vsb
    vsb is offline Member
    Join Date
    Oct 2011
    Posts
    17
    Rep Power
    0

    Default 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.

Similar Threads

  1. Java select Area of BufferedImage
    By nathic in forum New To Java
    Replies: 0
    Last Post: 03-10-2011, 09:52 AM
  2. Help with Robot class please
    By davetheant in forum New To Java
    Replies: 2
    Last Post: 01-04-2011, 12:13 PM
  3. Robot class
    By coltragon in forum New To Java
    Replies: 6
    Last Post: 07-12-2010, 05:54 PM
  4. Help with Robot Class
    By protocos in forum Eclipse
    Replies: 11
    Last Post: 10-05-2009, 08:15 PM
  5. Robot Class
    By Jessie Madman in forum New To Java
    Replies: 3
    Last Post: 05-15-2008, 04:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •