Skip to content

Commit

Permalink
aisingapore#443 - timeout step sikulix variable update
Browse files Browse the repository at this point in the history
SikuliX wait_timeout also needs to be changed as part of sikuli_step() when timeout step is used.

Otherwise, when present() or visible() is invoked, the SikuliX timeout setting gets reverted back to its internal variable.

Also, 'casper' object should be used in displaying the error message instead of 'this'. Otherwise, for the execution context, this would be undefined and error message does not show up.
  • Loading branch information
kensoh committed Jun 17, 2019
1 parent e4ef671 commit c0d0950
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/tagui_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ return false;}
// friendlier name to use check_tx() in if condition in flow
function present(element_locator) {if (!element_locator) return false;
if (is_sikuli(element_locator)) {var abs_param = abs_file(element_locator); var fs = require('fs');
if (!fs.exists(abs_param)) {this.echo('ERROR - cannot find image file for present step').exit();}
if (!fs.exists(abs_param)) {casper.echo('ERROR - cannot find image file for present step').exit();}
if (sikuli_step("present " + abs_param)) return true; else return false;}
else return check_tx(element_locator);}

// friendlier name to check element visibility using elementVisible()
function visible(element_locator) {if (!element_locator) return false;
if (is_sikuli(element_locator)) {var abs_param = abs_file(element_locator); var fs = require('fs');
if (!fs.exists(abs_param)) {this.echo('ERROR - cannot find image file for visible step').exit();}
if (!fs.exists(abs_param)) {casper.echo('ERROR - cannot find image file for visible step').exit();}
if (sikuli_step("visible " + abs_param)) return true; else return false;}
else {var element_located = tx(element_locator); var element_visible = casper.elementVisible(element_located);
// if tx() returns xps666('/html') means that the element is not found, so set element_visible to false
Expand Down Expand Up @@ -345,7 +345,8 @@ var fs = require('fs'); fs.write('tagui.sikuli'+ds+'tagui_sikuli.txt','','w');}
// for setting timeout in sikuli when looking for ui element
function sikuli_timeout(time_in_seconds) {var ds; if (flow_path.indexOf('/') !== -1) ds = '/'; else ds = '\\';
var fs = require('fs'); if (fs.exists('tagui.sikuli'+ds+'tagui_sikuli.in'))
sikuli_step('vision setAutoWaitTimeout(' + time_in_seconds.toString() + ')');}
sikuli_step('vision setAutoWaitTimeout(' + time_in_seconds.toString() + ')');
sikuli_step('vision wait_timeout = ' + time_in_seconds.toString());}

// for initialising integration with R
function r_handshake() { // techo('[connecting to R process]');
Expand Down
7 changes: 4 additions & 3 deletions src/test/positive_test.signature
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ return false;}
// friendlier name to use check_tx() in if condition in flow
function present(element_locator) {if (!element_locator) return false;
if (is_sikuli(element_locator)) {var abs_param = abs_file(element_locator); var fs = require('fs');
if (!fs.exists(abs_param)) {this.echo('ERROR - cannot find image file for present step').exit();}
if (!fs.exists(abs_param)) {casper.echo('ERROR - cannot find image file for present step').exit();}
if (sikuli_step("present " + abs_param)) return true; else return false;}
else return check_tx(element_locator);}

// friendlier name to check element visibility using elementVisible()
function visible(element_locator) {if (!element_locator) return false;
if (is_sikuli(element_locator)) {var abs_param = abs_file(element_locator); var fs = require('fs');
if (!fs.exists(abs_param)) {this.echo('ERROR - cannot find image file for visible step').exit();}
if (!fs.exists(abs_param)) {casper.echo('ERROR - cannot find image file for visible step').exit();}
if (sikuli_step("visible " + abs_param)) return true; else return false;}
else {var element_located = tx(element_locator); var element_visible = casper.elementVisible(element_located);
// if tx() returns xps666('/html') means that the element is not found, so set element_visible to false
Expand Down Expand Up @@ -372,7 +372,8 @@ var fs = require('fs'); fs.write('tagui.sikuli'+ds+'tagui_sikuli.txt','','w');}
// for setting timeout in sikuli when looking for ui element
function sikuli_timeout(time_in_seconds) {var ds; if (flow_path.indexOf('/') !== -1) ds = '/'; else ds = '\\';
var fs = require('fs'); if (fs.exists('tagui.sikuli'+ds+'tagui_sikuli.in'))
sikuli_step('vision setAutoWaitTimeout(' + time_in_seconds.toString() + ')');}
sikuli_step('vision setAutoWaitTimeout(' + time_in_seconds.toString() + ')');
sikuli_step('vision wait_timeout = ' + time_in_seconds.toString());}

// for initialising integration with R
function r_handshake() { // techo('[connecting to R process]');
Expand Down

0 comments on commit c0d0950

Please sign in to comment.