Java: Clicks but does not type?

Asked by Rahul Misra

I am trying to click in the browser url window and type an address. For some reason it clicks on the image (for the url) but that fails to type complaining, image not found.

Here is the code:

import org.sikuli.script.*;

public class T1 {

        public static void main(String[] args) {
                Screen s = new Screen();
                try{
                 App app = new App("C:\\Users\\rmisra\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
                 app.open();
                 Thread.sleep(2000);
                 app.focus();
                 s.highlight();
                 s.click("img/WWWgOOgICOfT.png", 0);
                 s.type("img/WWWgOOgICOfT.png", "http://finance.yahoo.com", 0);
                }
                catch(Exception e){
                        e.printStackTrace();
                }

        }
}

And this is what I get on execution:

[info] Windows utilities loaded.
[log] App.open C:\Users\rmisra\AppData\Local\Google\Chrome\Application\chrome.exe(4952)
[log] App.focus C:\Users\rmisra\AppData\Local\Google\Chrome\Application\chrome.exe(4952) #0
[log] toggle highlight Screen(1)[0,0 1920x1080] E:Y, T:3.0: true
[info] Sikuli vision engine loaded.
[log] CLICK on (190,339)
FindFailed: can not find img/WWWgOOgICOfT.png
Line ?, in File ?
        at org.sikuli.script.Region.handleFindFailed(Region.java:349)
        at org.sikuli.script.Region.wait(Region.java:420)
        at org.sikuli.script.Region.find(Region.java:308)
        at org.sikuli.script.Region.getLocationFromPSRML(Region.java:856)
        at org.sikuli.script.Region.click(Region.java:488)
        at org.sikuli.script.Region.type(Region.java:586)
        at T1.main(T1.java:14)

Any ideas why it is able to click but than not type in it? (Same works fine in py script recorded by IDE)

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Rahul Misra
Solved:
Last query:
Last reply:
Revision history for this message
Rahul Misra (rmisra) said :
#1

I resolved this as follows:

                 s.doubleClick("img/cxaboutzblan.png", 0);
                 s.type("img/cxaboutzblan.png", Key.BACKSPACE);
                 s.type("img/cxaboutzblan.png", "http://finance.yahoo.com" + Key.ENTER, 0);

Where img is of browser url text area.