GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sakuli/docs/manual/testdefinition/sakuli-api-environment.adoc at dev · ConSol/sakuli

Expand file tree

/

sakuli-api-environment.adoc

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
411 lines (270 loc) · 12.2 KB
/

sakuli-api-environment.adoc

Copy path

File metadata and controls

411 lines (270 loc) · 12.2 KB
Raw
Copy raw file
Download raw file
Edit and raw actions

Environment

git-link:docs/manual/testdefinition/sakuli-api-environment.adoc{git-view} | git-link:docs/manual/testdefinition/sakuli-api-environment.adoc{git-edit}

Environment - Represents the environment of the current test host.

Params

  • optResumeOnException Boolean - (optional) if this parameter is undefined, it will be false.

Members

  • Environment

  • Environment.setSimilarity(similarity)

  • Environment.resetSimilarity()

  • Environment.getRegionFromFocusedWindow()

  • Environment.takeScreenshot(filename)

  • Environment.takeScreenshotWithTimestamp(filenamePostfix, optFolderPath, optFormat)

  • Environment.sleep(seconds)

  • Environment.sleepMs(milliseconds)

  • Environment.getClipboard()

  • Environment.setClipboard(text)

  • Environment.pasteClipboard()

  • Environment.copyIntoClipboard()

  • Environment.cleanClipboard()

  • Environment.paste(text)

  • Environment.pasteMasked(text)

  • Environment.pasteAndDecrypt(text)

  • Environment.type(text, optModifiers)

  • Environment.typeMasked(text, optModifiers)

  • Environment.typeAndDecrypt(text, optModifiers)

  • Environment.decryptSecret(secret)

  • Environment.keyDown(keys)

  • Environment.keyUp(keys)

  • Environment.write(text)

  • Environment.mouseWheelDown(steps)

  • Environment.mouseWheelUp(steps)

  • Environment.isWindows()

  • Environment.isLinux()

  • Environment.getOsIdentifier()

  • Environment.runCommand(command, optThrowException)

  • Environment.getEnv(key)

  • Environment.getProperty(key)

Environment.setSimilarity(similarity)

Set a new default similarity for the screen capturing methods.

Params

  • similarity number - value between 0 and 1, default = 0.8

Returns: - this Environment or NULL on errors.

Environment.resetSimilarity()

Resets the current similarity of the screen capturing methods to the original default value of 0.8.

Returns: - this Environment or NULL on errors.

Environment.getRegionFromFocusedWindow()

Get a Region object from the current focused window

Returns: - a Region object from the current focused window or NULL on errors.

Environment.takeScreenshot(filename)

Takes a screenshot of the current screen and saves it to the assigned path. If there ist just a file name, the screenshot will be saved in your current testcase folder. Supported formats: jpg and png

Params

  • filename String - pathname/filename.format or just filename.format for example test.png.

Returns: Path - to the created screenshot OR null on errors Example

environment.takeScreenshot("test.png");
Environment.takeScreenshotWithTimestamp(filenamePostfix, optFolderPath, optFormat)

Takes a screenshot of the current screen and add the current timestamp in the file name like e.g.:

Params

  • filenamePostfix String - postfix for the final filename Default: screenshot

  • optFolderPath String - optional FolderPath, where to save the screenshot. If null or empty: testcase folder will be used

  • optFormat string - optional format, for the screenshot (currently supported: jpg and png) If null or empty use property sakuli.screenshot.format

Returns: Path - to the created screenshot OR null on errors Example

env.takeScreenshotWithTimestamp("my-screenshot");

saved under: mytestsuite/testcase1/2017_08_03_14_06_13_255_my_screenshot.png

Environment.sleep(seconds)

Blocks the current testcase execution for x seconds

Params

  • seconds number - to sleep

Returns: - this Environment or NULL on errors.

Environment.sleepMs(milliseconds)

Blocks the current testcase execution for x milliseconds

Params

  • milliseconds number - to sleep

Returns: - this Environment or NULL on errors.

Environment.getClipboard()

Returns: - the current content of the clipboard as String or NULL on errors

Environment.setClipboard(text)

sets the String parameter to the system clipboard

Params

  • text String - text as string

Returns: - this Environment.

Environment.pasteClipboard()

pastes the current clipboard content into the focused area. Will do the same as "CTRL + V".

Returns: - this Environment.

Environment.copyIntoClipboard()

copy the current selected item or text to the clipboard. Will do the same as "CTRL + C".

Returns: - this Environment.

Environment.cleanClipboard()

Clean the content of the clipboard.

Environment.paste(text)

pastes the text at the current position of the focus/carret <br/>using the clipboard and ctrl/cmd-v (paste keyboard shortcut)

Params

  • text String - a string, which might contain unicode characters

Returns: - this Environment or NULL on errors.

Environment.pasteMasked(text)

makes a masked paste(String) without any logging.

Params

  • text String - a string, which might contain unicode characters

Returns: - this Environment or NULL on errors.

Environment.pasteAndDecrypt(text)

combines pasteMasked(String) and decryptSecret(String).

Params

  • text String - encrypted secret

Returns: - this Environment or NULL on errors.

Environment.type(text, optModifiers)

Enters the given text one character/key after another using keyDown/keyUp. <p/> About the usable Key constants see documentation of Key. The function could also type UTF-8 unicode characters, if the OS supports it. The text is entered at the current position of the focus.

Params

  • text String - containing characters and/or Key constants

  • optModifiers String - (optional) an String with only Key constants.

Returns: - this Environment or NULL on errors.

Environment.typeMasked(text, optModifiers)

Enters the given text one character/key after another using keyDown/keyUp. The entered text will be masked at the logging. <p/> About the usable Key constants see documentation of Key. The function could also type UTF-8 unicode characters, if the OS supports it. The text is entered at the current position of the focus.

Params

  • text String - containing characters and/or Key constants

  • optModifiers String - (optional) an String with only Key constants.

Returns: - this Environment or NULL on errors.

Environment.typeAndDecrypt(text, optModifiers)

Decrypt and enters the given text one character/key after another using keyDown/keyUp. The entered text will be masked at the logging. For the details of the decryption see decryptSecret(String). <p/> About the usable Key constants see documentation of Key. The function could also type UTF-8 unicode characters, if the OS supports it. The text is entered at the current position of the focus.

Params

  • text String - containing characters and/or Key constants

  • optModifiers String - (optional) an String with only Key constants.

Returns: - this Environment or NULL on errors.

Environment.decryptSecret(secret)

Decrypt a encrypted secret and returns the value at runtime. The decryption will only work like described at https://github.com/ConSol/sakuli/blob/master/docs/manual/testdefinition/advanced-topics/sakuli-encryption.adoc . There will be no logging with the decrypted secret during this step. <p/> To create a encrypted secret see "sakuli-manual.md".

Params

  • secret String - encrypted secret as String

Returns: - decrypted String

Environment.keyDown(keys)

Press and hold the given keys including modifier keys <br/> use the key constants defined in class Key, <br/> which only provides a subset of a US-QWERTY PC keyboard layout <br/> might be mixed with simple characters<br/> use + to concatenate Key constants

Params

  • keys String - valid keys

Returns: - this Environment or NULL on errors.

Environment.keyUp(keys)

release the given keys (see Environment.keyDown(…)).

Params

  • keys String - valid keys

Returns: - this Environment or NULL on errors.

Environment.write(text)

Compact alternative for type() with more options

  • special keys and options are coded as #XN. or #X+ or #X- where X is a reference for a special key and N is an optional repeat factor
    A modifier key as #X. modifies the next following key the trailing . ends the special key, the + (press and hold) or - (release) does the same, but signals press-and-hold or release additionally.
    except #W / #w all special keys are not case-sensitive
    a #wn. inserts a wait of n millisecs or n secs if n less than 60
    a #Wn. sets the type delay for the following keys (must be > 60 and denotes millisecs)

  • otherwise taken as normal wait
    Example: wait 2 secs then type CMD/CTRL - N then wait 1 sec then type DOWN 3 times
    Windows/Linux: write("#w2.#C.n#W1.#d3.")
    Mac: write("#w2.#M.n#W1.#D3.")
    for more details about the special key codes and examples consult the sikuliX docs.

Params

  • text String - a coded text interpreted as a series of key actions (press/hold/release)

Returns: - this Environment or NULL on errors.

Environment.mouseWheelDown(steps)

move the mouse pointer to the given target location and move the wheel the given steps down.

Params

  • steps number - the number of steps

Environment.mouseWheelUp(steps)

move the mouse pointer to the given target location and move the wheel the given steps up.

Params

  • steps number - the number of steps

Environment.isWindows()

Returns: boolean - true, if the OS is any instance of an Windows based OS

Environment.isLinux()

Returns: boolean - true, if the OS is any instance of an Linux based OS

Environment.getOsIdentifier()

Returns: string - identifier of the current OS

Environment.runCommand(command, optThrowException)

Runs the assigned command on the host and returns the result. Attention: this is OS depended feature! So be aware which os you are running, maybe us to check Environment#isLinux() or Environment#isWindows().

Params

  • command string - OS depended command as String

  • optThrowException boolean - defines if an exception should be thrown, if the exit code != 0

Returns: - the result as CommandLineResult object, you can use the methods result.getOutput() and result.getExitCode()

Example:

var app;
if(environmen.runCommand('uname --machine') == 'x86_64'){
    //open app from other path
    app = new Application('/lib64/appname');
} else {
    app = new Application('/lib/appname');
}
Environment.getEnv(key)

Reads out the environment variable with the assigned key

Params

  • key string - of environment variable

Returns: string - value or null

Environment.getProperty(key)

Reads out the property value with the assigned key

Params

  • key string - of property

Returns: string - value or null

You are visitor 01402860 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.