[2.0.x] switchApp not telling apart windows of the same application --- accepted as bug

Asked by Romuald C.

accepted bug tracked on GitHub: https://github.com/RaiMan/SikuliX1/issues/587
--------------------------------------------------------------------------------------------------------------------------

I'm currently trying to upgrade Sikuli from 1.1 (1.1.1) to 2.0 (2.0.4) and facing a strange behavior with switchApp: if I have 2 windows of the same application (let's say two Google Chrome windows), switchApp seems unable to tell them apart and always selects the one focused last.

For example
1. Open two chrome windows (in this order)
  * One on https://launchpad.net/sikuli
  * Another on https://www.perdu.com/
2. Open another application (e.g. explorer, notepad, ...) (optional, just to see application switching)
3. From Sikuli, call switchApp("Launchpad")

Results
* with Sikuli 1.1: switching to Chrome window with Launchpad site opened
* with Sikuli 2.0.4: switching to Chrome window with perdu.com

Is there anything to do to have, with 2.0, a behavior similar to what I had in 1.1?
In other words: was I doing something bad in 1.1 that worked anyway and should be fixed in 2.0?

I tried many things with no luck
I search our f(r)iend Internet (inc. here on Launchpad) but did not find something even similar.

Thanks,
Romuald

Environment
* Windows 10
* OpenJDK (Temurin)(build 1.8.0_372-b07)

Question information

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

I will check and come back later.

Any need to stick to Java 8?
Possible to switch to Java 11+? Then you could try with 2.0.5

Revision history for this message
Romuald C. (romualdc) said :
#2

Thanks for the quick answer Raiman

Alas, same behavior with 2.0.5 (tried Java 11 & 17)

(No need to stick to 8, no; I picked 8 because it was LTS but did not see 11 was LTS too)

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

Sorry, but I have to confirm the behavior.

Even in 2.0.6, where some App class enhancements have been made, it is not working.
So I do not have any solution using SikuliX App features currently.

But this might be a workaround:
having 2 or more Chrome windows/tabs open:

switchApp("Google")
wait(1) # might not be needed
type("a", Key.SHIFT+Key.CTRL) # start tab search
type("part of window/tab title")
type(Key.ENTER)
wait(3)

Revision history for this message
RaiMan (raimund-hocke) said :
#4
Revision history for this message
Romuald C. (romualdc) said :
#5

Thanks for the confirmation (I thought I was going mad) and the workaround

If anyone needs to know, workaround works as long as Chrome is concerned (and something similar exists for Firefox)

Sorry for the very late answer and thank you for maintaining this wonderful tool