Results 1 to 12 of 12
  1. #1
    pratheshbv is offline Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0

    Default need Quick help for Automation using Robot class

    Hi I am doing Automation task using Robot class . I have to execute a exe file , a window will open having some text box .
    The issue is i have to take value from a properties file and same value have to place in the text box.
    I have taken value from property file . can any body tell how to set it in the textbox.
    i Have used as robot.keyPress(str);
    its not working . please suggest.
    Thanks

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default Re: need Quick help for Automation using Robot class

    What does "it's not working" mean? Do you get a compilation error, a runtime Exception, some strange behavior, something else? Where is your MCVE?
    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
    pratheshbv is offline Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0

    Default Re: need Quick help for Automation using Robot class

    Hi plz find below code
    void keyEvent() {
    try {
    String str="data";
    Robot robot = new Robot();
    robot.delay(1000);
    robot.keyPress(KeyEvent.VK_TAB);
    robot.delay(1000);
    robot.keyPress(KeyEvent.VK_TAB);
    robot.delay(1000);
    robot.keyPress(KeyEvent.VK_TAB);
    robot.delay(1000);
    robot.keyPress(KeyEvent.VK_DOWN);
    robot.delay(1000);
    robot.keyPress(KeyEvent.VK_DOWN);
    robot.delay(1000);
    robot.keyPress(KeyEvent.VK_TAB);
    robot.delay(1000);
    robot.keyPress(KeyEvent.VK_TAB);
    robot.keyPress(str);
    Below id the error
    Multiple markers at this line
    - The method keyPress(int) in the type Robot is not applicable for the arguments
    (String)
    - The method typeKeys(String) is undefined for the type Robot

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default Re: need Quick help for Automation using Robot class

    Well, the error says it all. You're passing an entire String into a method that only takes a single character.
    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
    pratheshbv is offline Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0

    Default Re: need Quick help for Automation using Robot class

    Ya Kevin , I have to pass entire string from properties file How can i pass , Is there any way to do that

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default Re: need Quick help for Automation using Robot class

    Quote Originally Posted by pratheshbv View Post
    Ya Kevin , I have to pass entire string from properties file How can i pass , Is there any way to do that
    Break the String down into individual characters and send them into the method one at a time.
    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
    pratheshbv is offline Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0

    Default Re: need Quick help for Automation using Robot class

    Realy Thankz kevin , Can you expalin with a sample code please

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default Re: need Quick help for Automation using Robot class

    Quote Originally Posted by pratheshbv View Post
    Realy Thankz kevin , Can you expalin with a sample code please
    No. Can you provide the code you've attempted to break a String down into individual characters?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: need Quick help for Automation using Robot class

    To be fair that's a bit vaguely described especially if English is not your primary language.

    The String class has a charAt() method with which you can get the character at a specific index in the String:

    String (Java Platform SE 7 )
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  10. #10
    pratheshbv is offline Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0

    Default Re: need Quick help for Automation using Robot class

    Thankz kevin i used below its working fine now
    String Str = "abc";
    char characters[];
    stringLength = Str.length();
    characters = Str.toCharArray();

    for (int i = 0; i <= stringLength; i++) {
    robot.keyPress(characters[i]);
    }

  11. #11
    pratheshbv is offline Member
    Join Date
    Jul 2014
    Posts
    9
    Rep Power
    0

    Default Re: need Quick help for Automation using Robot class

    But here the issue im facing here is my input string is like tmp0590.dat , While spliting the string its giving output like -0590.41. How to resolve this issue

  12. #12
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default Re: need Quick help for Automation using Robot class

    What output?

    The Robot.keyPress() method takes an int. Those ints are defined as key presses in the KeyEvent class. For example, the 'A' key is represented by KeyEvent.VK_A. That's what you want to pass into the Robot.keyPress() method, not the 'A' character value.

    Splitting the String into individual characters is only half the battle. You have to then convert those characters to KeyEvent codes, then pass those into the method.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Help with Robot class please
    By davetheant in forum New To Java
    Replies: 2
    Last Post: 01-04-2011, 01:13 PM
  2. Robot class
    By coltragon in forum New To Java
    Replies: 6
    Last Post: 07-12-2010, 06:54 PM
  3. Help with Robot Class
    By protocos in forum Eclipse
    Replies: 11
    Last Post: 10-05-2009, 09:15 PM
  4. Robot Class
    By Jessie Madman in forum New To Java
    Replies: 3
    Last Post: 05-15-2008, 05:13 AM
  5. Robot Class
    By jfredrickson in forum New To Java
    Replies: 2
    Last Post: 07-11-2007, 10:00 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
  •