0

I am working on an automation project using selenium webdriver and sikuli, however when i run the first test i get the following error:

[error] Image: could not be loaded: file:/C:/bla/bla/pic/SingInBtn.PNG [error] Image: Image not valid, but TextSearch is switched off!

I am using java, and this is my sample code:

public void login(
                   String username,
                   String password ) {

    driver.type( this.element.userNameTxt(), username );
    driver.type( this.element.passwordTxt(), password );

    try {
        Pattern pattern = new Pattern( "pic/SingInBtn.PNG" );
        screen.click( pattern );
    } catch( FindFailed e ) {}
    //driver.click( driver.elementFinder.findElementByXpath( "" ) );
}

could you please tell me how could i turn on the textsearch on?

thanks

Ali Hamadi
  • 673
  • 3
  • 11
  • 26

1 Answers1

0

Your problem does not seem to be the TextSearch which is Sikuli's functionality for OCR based pattern detection. In your case, the image file you have provided as a pattern cannot be located during the execution. That, in its turn, can happen as a result of incorrect path, corrupted file, unsupported file, etc.. When Sikuli encounters that problem it assumes that what you have provided is a plain text rather than a image pattern file and it tries to search for that text on the screen and eventually fails with the error you have specified.

To diagnose this problem, make sure that the path you are using is correct and the image file is there. To identify what is the current configured path, have a look at the output of the below method:

System.out.println(ImagePath.getBundlePath());

Also make sure that the file itself is valid.

P.S. I would also try to use an absolute path or, if that's undesired, detect the path dynamically during the execution.

Eugene S
  • 6,709
  • 8
  • 57
  • 91
  • Thank you #Eugene, by the way the file is correct i had to add the complete path, but when i try to load the picture from my project directory i got the mentioned error, do you have any idea what could be the reason? – Ali Hamadi Oct 13 '16 at 08:03
  • @AliHamadi I am not sure what is your question exactly. I explain in my above answer why it happens. If you are not sure where Sikuli is looking for pattern files print the bundle path as I describe above. – Eugene S Oct 13 '16 at 09:12