How to switch image sets having the same image filenames but being in different folders

Asked by Naidu

Here is my following scenario.

I have to automate same tests in 4 different browsers.
I divided the images into 4 categories and all the images are with same name.
Each browser has a separate class & load the images in their respective directories.

ImagePath.add(Constants.IMG_DIR + browser);

When i run each browser tests individually everything went well.

The issue arise when i run all browser tests in a batch. because each browser folder contains the same image names, sikuli won't load the images again.

Is there any reload Or unload methods available which can clear the cache of images that are already loaded in sikuli?

Or is there any other way which can be used to avoid these.

The last option is to rename the images, which is not an easy task for me as it involves good amount of changes.

Question information

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

the problem in your case is the ImagePath.

each ImagePath.add() adds the path to the end of the list.

so the images are always found in the path added first.

In your case the easiest solution is to use
ImagePath.setBundlePath(Constants.IMG_DIR + browser);

instead of ImagePath.add()

because ImagePath.setBundlePath() always overwrites the first entry in the image path list.

BTW: the concept you have chosen is exactly the one that should be used. In version 2 I will support this even better with an ImageGroup concept based on folder structures and option files.

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

Another possibility is to do the following in some batch scenario like unittest:

- in a setup for the testcase use ImagePath.add(path)
- in a teardown after testcase completion use ImagePath.remove(path)

This currently would be the solution, if more than one path changes from testcase to testcase

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

... and there is another option (1.1.0+)

ImagePath.reset()

which would empty the ImagePath list.

Revision history for this message
Naidu (myqafreelance) said :
#4

Thanks a lot raiMan.

I guess i reset() is something i am looking for.
Will work with it and update you, if any issues.