Mac: Java: with Selenium Firefox: images not found in browser window

Asked by avisha

I am using OS X Version (10.11.6)MacBook Pro
Eclipse IDE Version: Neon Release (4.6.0)
SikuliX1.1.0

now even a simple code of sikuli is not working on my system i have tried very other way but still confused and yes i am new to sikuliplease help below is my code and path to my image folder.and on my system i have placed sikuli jar at this location
*******JARPATH********************************************
::/Users/vishalsrivastava/Documents/JARS/SikuliJar/sikulixapi.jar
**********ERROR*****************************************************
Error I am getting is ::FindFailed: can not find P(/Users/vishalsrivastava/Documents/workspace/SeleniumTest/imgs/gmail.png) S: 0.7 in S(0)[0,0 1280x800]
  Line 2189, in file Region.java

************CODE*********************************

package sikuli;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.sikuli.script.*;

public class TestSikuli {

 public static void main(String[] args) {
  WebDriver driver=new FirefoxDriver();
  driver.get("http://google.com/");
  driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
  Screen s = new Screen();
  try{
   Pattern gmail=new Pattern("/Users/vishalsrivastava/Documents/workspace/SeleniumTest/imgs/gmail.png");
   s.click(gmail);

  }
  catch(FindFailed e){
   e.printStackTrace();
  }

 }

}

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

I guess, to start Firefox and show the google page lasts more than 3 seconds.

try this instead of s.click(gmail);

s.click(s.wait(gmail, 10));

this waits 10 seconds for the image to appear.

Revision history for this message
avisha (1priyankavisha) said :
#2

I tried it still i am getting same error.Is there any way I can share screenshots or attachments on this page??
Thanks for looking into it.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

the images do not help.

try the latest 1.1.1:
http://sikulix.com

Revision history for this message
avisha (1priyankavisha) said :
#4

I did as u said but no success still same error ,This time i was trying to click on SignIn button on google page.What else can be the problem??Is there any problem in folder structure where sikuli is looking for image versus where i have stored them .I am trying every possible ways but sikuli keeps giving same error.Moreover i see some .Png files like firefox.png,btnnightly.png etc in ImagesAPI.sikuli folder in eclipse What is purpose of those ??they can't be opened or copied or anything.Please help
error::
FindFailed: /Users/vishalsrivastava/Documents/workspace/SeleniumTest/imgs/signin.png: (138x66) in S(0)[0,0 1280x800] E:Y, T:3.0

Revision history for this message
RaiMan (raimund-hocke) said :
#5

I will try to test with your environment later today.

Revision history for this message
avisha (1priyankavisha) said :
#6

Thanks I am trying on my level too

Revision history for this message
avisha (1priyankavisha) said :
#7

package sikuli;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.sikuli.script.*;
import org.sikuli.script.ImagePath.PathEntry;

public class TestSikuli {

 public static void main(String[] args) throws FindFailed {

        Screen s = new Screen();
//trying to get image bundle path
                      String paths = ImagePath.getBundlePath();
         System.out.println(paths);
       Pattern fire=new Pattern("//Users//vishalsrivastava//Documents//workspace//SeleniumTest//fire.png");

                         s.click(s.wait(gmail, 10));
   s.click(fire);

   }

}

As u see in above code i tried to get the image bundle path which came out to be :: //Users//vishalsrivastava//Documents//workspace//SeleniumTest
so i placed my firefox image under given image path
but the moment Java runtime reaches the pattern line it throws this
 exception::Exception in thread "main" FindFailed: //Users//vishalsrivastava//Documents//workspace//SeleniumTest//fire.png: (136x170) in S(0)[0,0 1280x800] E:Y, T:3.0
  Line 2716, in file Region.java

Revision history for this message
RaiMan (raimund-hocke) said :
#8

It seems, that running such code from inside an IDE (Eclipse in your case, I tried with IntelliJ) does not bring the Firefox window to front, hence it is not visible and images cannot be found.

Take care, that FF comes to front after start (e.g. use SikuliX's class App).

Revision history for this message
avisha (1priyankavisha) said :
#9

Hello Raiman
 ,lets say I i open my firefox using
WebDriver driver=new FirefoxDriver();
now using driver.get("http://google.com/");
I open google page as well,
there after code fails when I try to look for pattern of image on mms system.coz its not getting the image anywhere in my system
but in fact its there at given path.
problem is not about opening browser coz i am already doing that using wedriver class and its up and running and google page is also opened.
hope u got my point here.
Thanks

Revision history for this message
RaiMan (raimund-hocke) said :
#10

Sorry, but I fully understood, what you are doing there ...
... and I did the same in my test with the exception, that I am on IntelliJ IDEA.

The problem I found was, that the browser window was NOT VISIBLE in front of the IDE GUI window, but instead behind it.
The Selenium stuff indeed worked correctly and opened the Google page.

SikuliX only sees the pixels on the screen.

... hope YOU got my point here now.

Can you help with this problem?

Provide an answer of your own, or ask avisha for more information if necessary.

To post a message you must log in.