MarketSquare / MarketSquare/robotframework-SikuliLibrary

Set Scan Wait Rate doesnt set scan rate properly.

Open
#189 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
163
Forks
60
PR merge metrics
No merged PRs in 30d

Description

Hey there, thankyou for this library, so far its great!

When playing with the Set Scan Rate key word, I noticed that the set scan rate doesn't seem to apply properly.

I dont have an IDE available, nor do I have a example script to demonstrate this at the moment otherwise I would do a pull request or give the script to demonstate... But the problem is due to the following:

```
@RobotKeywords
public class ScreenKeywords {

private static double DEFAULT_TIMEOUT = 3.0;
private static Screen screen = new Screen();
private static Region region = new Region(screen);
```

Note in ScreenKeywords.java, the region is created

and in SettingsKeywords.java

This is good, but this is an issue with how the Region class is then initialised in SikuliApi, which at its initialisation, it only ever calls Settings.WaitScanRate once.

```
public class Region extends Element {
...
/**
* set the regions individual WaitScanRate
*
* @param waitScanRate decimal number
*/
public void setWaitScanRate(float waitScanRate) {
this.waitScanRate = waitScanRate;
}

private float waitScanRateDefault = Settings.WaitScanRate;
private float waitScanRate = waitScanRateDefault;
```

So the following logic, doesn't quite control the scan rate for the region defined in the region key words.
```
@RobotKeyword("Set wait scan rate" + "\n Specify the number of times actual search operations are performed per second while waiting for a pattern to appear or vanish.")
@ArgumentNames({"delay"})

public void setWaitScanRate(float scanRate) {
Settings.WaitScanRate = scanRate;
}
```

So this is where it gets a little tricky because the two classes containing the key words don't effectively work with one-another.

Could always do the lazy option and move the Set wait scan rate into ScreenKeywords.java and then do a
region.setWaitScanRate(float scanRate) instead (I wont complain, this will solve my issue ;) )

or.. if you are looking for a cleaner/ more elegant solution..

Create a settings class service, with an inbuilt observer pattern to notify settings changes made from SettingsKeywords.java to ScreenKeywords.java.

I would normally suggest DI, but being that I'm not super experienced with robot keywords yet and how that impacts keyword registration, A Singleton pattern may be better suited here even though its more of a anti-pattern.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how ScreenKeywords.java creates its Region and how SettingsKeywords.java changes Settings.WaitScanRate, then inspect Region initialization in SikuliApi. Determine how an existing region should receive later scan-rate changes; done means the Set wait scan rate keyword controls the region used by the screen keywords, with appropriate behavior verified in the relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.