Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How can i point the mouse over a html element within the web browser?

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can i point the mouse over a html element within the web browser?

    Hi,

    I am writing a functional test automation script to automate the file upload feature of a web application. I am using a tool called selenium to operate on the browser. This tool however does not support clicking on the file upload control hence I want to do this operation using java robot.

    First I need to move the mouse pointer onto the html element (file upload control) displayed within a html page. I believe to do that i need to get the coordinates of the html element. I tried with the offsetLeft and offsetTop but those are just the relative coordinates (relative to the html document). I need the absolute screen coordinates. Is there a way to get the absolute screen coordinates? If not can you suggest a different approach?

    Thanks for reading
    Last edited by bobomonkey; October 18th, 2009 at 07:58 AM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: How can i point the mouse over a html element within the web browser?

    You could try making it so that your robot will run when the screen is maximized, then the offsets are more or less based off of the whole screen.

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can i point the mouse over a html element within the web browser?

    The offset value is relative to the html file displayed within the browser. It does not take into account the menubar, toolbar or status bar of the browser. But the robot.mousemove(x,y) function takes absolute screen coordinates. BTW I am running the browser in maximized mode.

Similar Threads

  1. How to get Mouse Position even if it is not within our application?
    By Freaky Chris in forum Java Programming Tutorials
    Replies: 2
    Last Post: January 4th, 2012, 10:57 AM
  2. How to Grab the HTML source code of a website URL index page?
    By JavaPF in forum Java Networking Tutorials
    Replies: 6
    Last Post: April 22nd, 2010, 02:46 PM
  3. Concatenating string with html tag
    By subhvi in forum Java Theory & Questions
    Replies: 4
    Last Post: September 29th, 2009, 05:47 AM
  4. Replies: 4
    Last Post: June 18th, 2009, 09:23 AM