Screen text (FR)

Perfecto Command

mobile:screen:text

Purpose

Returns the text that appears on the screen of the device (but does not select the text). The retrieved screen text can be stored in a defined String variable or to a location in the Perfecto Repository (see key parameter) and then used with the string compare and string attribute checkpoints.

Parameters

The command can take on the parameters listed in the following table. In addition, the General Visual Analysis common parameters are supported.

Name

Type

Possible Values

Description

key

String


The full repository path, including directory and file name, where to save the screen text.

Example: PRIVATE:dir1/screenText.txt

The text will always be available in the report.

context

String

all | body

Defines the screen region where to retrieve the text.

content1

String

 

To ensure that the needle will still be found if the OCR misses a few characters, consider using the entire string searched for.

1 Not including the content parameter for desktop web results in the following error:

Copy
500 : "{"timestamp":"2023-08-17T13:24:25.749+00:00","status":500,"error":"Internal Server Error","message":"WFA-400-0004 - bad/missing analysis-request inputs. ","path":"/wfa/v1/session/command"}"

Return Value

The full text identified on the device screen.

Following is a passing result sample when utilizing the content parameter.

Copy

Result sample when using the content parameter

vy x Web & Mobile App Testing I Cor X + <- -ยป c A perfecto.io As Chrome is being controlled by automated test software. X Q & Perfecto Release High-Quality Apps, With Confidence P erf ecto i s a proven, ent erpri setestautomationpiatformfor power! ng S-sta

Exceptions

None

Examples

Copy

Java sample

Map<String, Object> params = new HashMap<>();
params.put("context", "body");
String res = (String)driver.executeScript("mobile:screen:text", params);
// res value will be a string that includes all text identified on the screen body 
Copy

C# sample

Dictionary<String, Object> pars = new Dictionary<String, Object>();
pars.Add("key", "PRIVATE:text/scrren12Feb.txt");
driver.ExecuteScript("mobile:screen:text", pars);
/* text from screen copied into the Repository file identified