Desktop App
Desktop App automation is currently only available in Ruby
The Spark Desktop App driver is available if you have configured test_types in config.yml to include desktop_app
or selected the test_type desktop_app
in Flare.
Windows, MacOS and Linux distributions are supported but may have specific requirements. Check the list of pre-requisites before starting.
- Ruby
- JavaScript
- TypeScript
TestEvolve.desktop_app
Not yet implemented
Not yet implemented
Screen Object Model
Similar to the page object class, elements are defined at the top of the class and these can be referenced in methods. These elements are defined as the relative path from the directory specified under image_directory in desktop_app.yml.
For an image stored in c:/my_test_evolve_project/features/support/images/ok.png
the following values would be used:
image_directory: features/support/images
element: ok.png
- Ruby
- JavaScript
- TypeScript
If you are using a new module to group your screen objects, ie/ module Screens then you must add it to the World.rb file in the features/support
folder.
World(Pages, Screens)
An example of a screen object class can be found below.
module Screens
def customer_creation_screen
@customer_creation_screen ||= CustomerCreationScreen.new
end
class CustomerCreationScreen < TestEvolve::Core::ScreenObject
element(:ok_button) { 'ok.png' }
def select_ok
ok_button.click
end
end
end
This would then be called from the step definition layer like this: customer_creation_screen.select_ok
Not yet implemented
Not yet implemented
Type
To send a string of characters to the screen from the Screen Object class, use the following command:
- Ruby
- JavaScript
- TypeScript
type('example text')
You can also specify the interval (in seconds) between each key press, using the following command:
type('example text', interval: 0.5)
Not yet implemented
Not yet implemented
Press Key
To send a specific character or special character to the screen from the Screen Object class, use the following command:
- Ruby
- JavaScript
- TypeScript
Pass through the key as a symbol
press_key(:enter)
press_key(:f1)
press_key(:f12)
Not yet implemented
Not yet implemented
Element
When an element is defined there are a number of actions that can be performed on it.
The action will be performed once the defined element image has been found on the screen.
This will timeout if the subimage can not be found within the timeout configured as find_timeout
in desktop_app.yml.
Click
When click is called on an element, Spark will search the screen for the defined image and click on the centre of it.
- Ruby
- JavaScript
- TypeScript
element.click
Not yet implemented
Not yet implemented
Double Click
When double click is called on an element, Spark will search the screen for the defined image and click on the centre of it.
- Ruby
- JavaScript
- TypeScript
element.double_click
Not yet implemented
Not yet implemented
Exists
When exists is called on an element, Spark will search the screen for the defined image and return true if the image is found. It will return false if the image is not found.
- Ruby
- JavaScript
- TypeScript
element.exists?
Not yet implemented
Not yet implemented
Exists Within (secs)
Exists within will return true if the element image is located within the specified number of seconds. It will return false if the element image is not located in the specified number of seconds.
- Ruby
- JavaScript
- TypeScript
element.exists_within(5)
Not yet implemented
Not yet implemented
Example usage:
- Ruby
- JavaScript
- TypeScript
element(:error_message) { 'error_message.png' }
def verify_error_message
raise 'Error message was not displayed' unless error_message.exists_within(5)
end
Not yet implemented
Not yet implemented
Offset
Offset allows you to specify an offset from the found images location. This returns a new Region
that behaves in the same way as an element.
- Ruby
- JavaScript
- TypeScript
The offset method takes the following arguments and returns a new Region
.
- offset_x: the number of pixels from the left of the element
- offset_y: the number of pixels from the top of the element
- width: the width (in pixels) of the region from the offset point
- height: the height (in pixels) of the region from the offset point
element.offset(offset_x: 300, offset_y: 0, width: 200, height: 60)
Not yet implemented
Not yet implemented
Example usage:
- Ruby
- JavaScript
- TypeScript
element(:text_field_label) { 'text_field_label.png' }
def text_from_text_field
text_field_label.offset(offset_x: 300, offset_y: 0, width: 200, height: 60).text
end
Not yet implemented
Not yet implemented
Region
A Region is returned by an offset and is a subsection of the entire screen.
Click
When click is called on a region
, Spark click on the centre of it.
- Ruby
- JavaScript
- TypeScript
region.click
Not yet implemented
Not yet implemented
Double Click
When double click is called on a region
, Spark will click on the centre of it.
- Ruby
- JavaScript
- TypeScript
region.double_click
Not yet implemented
Not yet implemented
Text
When text is called on a region
, Spark will use an integration to Tesseract to recognise characters in the image and return the text.
- Ruby
- JavaScript
- TypeScript
region.text
Not yet implemented
Not yet implemented
Example usage:
- Ruby
- JavaScript
- TypeScript
element(:text_field_label) { 'text_field_label.png' }
def text_from_text_field
text_field_label.offset(offset_x: 300, offset_y: 0, width: 200, height: 60).text
end
Not yet implemented
Not yet implemented
Mouse
If you are not using a specific element and need to control the mouse directly with x and y co-ordinates then the following methods are available.
- Ruby
- JavaScript
- TypeScript
TestEvolve.mouse
Not yet implemented
Not yet implemented
Click
To click directly on the screen at specific x and y co-ordinates, use the following command:
- Ruby
- JavaScript
- TypeScript
TestEvolve.mouse.click(x, y)
Not yet implemented
Not yet implemented
Double Click
To double-click directly on the screen at specific x and y co-ordinates, use the following command:
- Ruby
- JavaScript
- TypeScript
TestEvolve.mouse.double_click(x, y)
Not yet implemented
Not yet implemented
Move
To move the mouse to specific x and y co-ordinates, use the following command:
- Ruby
- JavaScript
- TypeScript
TestEvolve.mouse.move(x, y)
Not yet implemented
Not yet implemented
Other
Lower level interactions with the mouse are also available, which allows users to create actions such as swipe or drag and drop.
Press
To press the mouse button down:
- Ruby
- JavaScript
- TypeScript
TestEvolve.mouse.press(x, y)
Not yet implemented
Not yet implemented
Release
To release the mouse button:
- Ruby
- JavaScript
- TypeScript
TestEvolve.mouse.release(x, y)
Not yet implemented
Not yet implemented
Keyboard
In order to interact directly with the keyboard, the following methods are available:
- Ruby
- JavaScript
- TypeScript
TestEvolve.keyboard
Not yet implemented
Not yet implemented
Type
To send a string of characters to the desktop application via the keyboard, use the following command:
- Ruby
- JavaScript
- TypeScript
TestEvolve.keyboard.type('example text')
You can also specify the interval (in seconds) between each key press, using the following command:
TestEvolve.keyboard.type('example text', interval: 0.5)
Not yet implemented
Not yet implemented
Press Key
To send a specific character or special character to the desktop application via the keyboard, use the following command:
- Ruby
- JavaScript
- TypeScript
Pass through the key as a symbol
TestEvolve.keyboard.press_key(:enter)
TestEvolve.keyboard.press_key(:f1)
TestEvolve.keyboard.press_key(:f12)
Not yet implemented
Not yet implemented