SeeTestAutomation- CaptureElement
Please note that this tool is classified as a Legacy tool. We recommend transitioning to our updated solutions to maintain optimal performance and security in your workflows. For more information on this matter, please reach out to technical support .
void captureElement(name, x, y, width, height, similarity)
Note: This command is available only from a code environment.
Description
The command enables you to capture a screenshot of a part of the device’s screen in a given time and create a new element in zone "runtime" that you can use in later steps of your scripts.
Parameters
- String name: Name that will be given to the captured Element
- Int X: First point X
- Int Y: First point Y
- Width: Width of the captured area
- Height: Height of the captured area
- Similarity: Integer number between 80-100. Enables to define the tolerance of changes when searching for the image.
Usage
Designed command for image recognition during runtime.
This can be highly useful when the elements on the screen changes very often or for image comparisons.
Scenario: We will use captureElement command to capture the Calendar icon image during runtime and then click on the icon using this image.
Parameters:
- name: Will be set to Calendar
- X: will be set to 275
- Y: will be set to 255
- Width: will be set to 264
- Height: will be set to 299
- Similarity: will be set to 100
The values of the coordinates were retrieved using the offline tab.
Once executed, new object is created on zone runtime with the name Calendar.
Which can be used to identify the element in order to operate on it.
We will add a click command to click on the icon
Code:
//package <set your test package>;
import com.experitest.client.*;
import org.junit.*;
/**
*
*
*/
public class captureElement {
private String host = "localhost";
private int port = 8889;
private String projectBaseDirectory = "C:\\Users\\user_12\\workspace\\project2";
protected Client client = null;
@Before
public void setUp(){
client = new Client(host, port, true);
client.setProjectBaseDirectory(projectBaseDirectory);
client.setReporter("xml", "reports", "EriBank");
}
@Test
public void testcaptureElement(){
client.setDevice("adb:Nexus 5");
client.captureElement("Calendar", 275, 255, 264, 299, 100)
client.click("runtime", "Calendar", 0, 1)
}
@After
public void tearDown(){
// Generates a report of the test case.
client.generateReport(false);
// Releases the client so that other clients can approach the agent in the near future.
client.releaseClient();
}
}
Code Examples
Java Example
client.captureElement("Calendar", 275, 255, 264, 299, 100)
client.click("runtime", "Calendar", 0, 1)
C# Example Expand source
client.captureElement("Calendar", 275, 255, 264, 299, 100)
client.click("runtime", "Calendar", 0, 1)
Python Example Expand source
self.client.captureElement("Calendar", 275, 255, 264, 299, 100)
self.client.click("runtime", "Calendar", 0, 1)