Sikuli object identification fails if the browser is not in foreground

Asked by Satheesh on 2017-05-18

In our environment, at times, the browser may not be in the foreground ,

This makes the object identification to fail and the entire test fails.

Is there a way to ensure or bring the browser to fore ground before performing sikuli scripts.

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2017-05-19
Last reply:
2017-05-19
masuo (masuo-ohara) said : #1

The solution depends on the environment.
When os is Windows, App.focus() feature is valid.
http://sikulix-2014.readthedocs.io/en/latest/appclass.html?highlight=focus

[example:]
App.focus("chrome")

Satheesh (satheesh.jey) said : #2

This is what I have tried,

I am running my tests on VM and the problem here is when the browser window is kept in fore Ground, object identification passes but if its in back ground, it fails.

I have tried

App appBrowser = new App("Internet Explorer");
appBrowser.focus();
Screen s = appBrowser.window().getScreen();

This does not bring the screen to fore ground.

1) Recently I used
switchApp(application) ( http://sikulix-2014.readthedocs.io/en/latest/interaction.html ), on Mac.
You may want to give it a try.

2) A few times I used approach not involving AppFocus()

a) Checked if browser window is on foreground searching for some title image
b) If it is not, invoke click on application icon in Taskbar (or Dock or whatever is other system way to bring app to front)

Can you help with this problem?

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

To post a message you must log in.