Skip to content

Commit dadcd4d

Browse files
committed
trace and map --diff: examples in every client
app_trace landed on mobium main in #60 with no example, which the generator refuses. Its start and stop are examples in all five clients, and map --diff is a second app_map scenario. The trace page says why it has no screenshot: what it keeps is a zip for the Playwright viewer.
1 parent 7e8cb3e commit dadcd4d

7 files changed

Lines changed: 81 additions & 0 deletions

File tree

‎examples/canonical.json‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,13 @@
394394
"title": "Map what can be acted on, with a ref for each",
395395
"cli": "mobium map",
396396
"args": {}
397+
},
398+
{
399+
"title": "What the last action changed",
400+
"cli": "mobium map --diff",
401+
"args": {
402+
"diff": true
403+
}
397404
}
398405
],
399406
"app_network": [
@@ -712,6 +719,24 @@
712719
}
713720
}
714721
],
722+
"app_trace": [
723+
{
724+
"title": "Start tracing the session",
725+
"cli": "mobium trace start --name \"sign in\"",
726+
"args": {
727+
"action": "start",
728+
"name": "sign in"
729+
}
730+
},
731+
{
732+
"title": "Stop, and save the trace",
733+
"cli": "mobium trace stop -o sign-in.zip",
734+
"args": {
735+
"action": "stop",
736+
"path": "sign-in.zip"
737+
}
738+
}
739+
],
715740
"app_type": [
716741
{
717742
"title": "Type after what a field holds",

‎examples/dotnet.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@
204204
"app_map": [
205205
{
206206
"code": "foreach (var e in device.Map())\n Console.WriteLine($\"{e.Ref} {e.Role} {e.Label}\");"
207+
},
208+
{
209+
"code": "var diff = device.MapDiff();\nConsole.WriteLine(diff[\"added\"]);\nConsole.WriteLine(diff[\"changed\"]);"
207210
}
208211
],
209212
"app_network": [
@@ -369,6 +372,14 @@
369372
"code": "string zone = device.Timezone(\"Asia/Tokyo\");"
370373
}
371374
],
375+
"app_trace": [
376+
{
377+
"code": "device.TraceStart(\"sign in\");"
378+
},
379+
{
380+
"code": "var saved = device.TraceStop(\"sign-in.zip\");\nConsole.WriteLine($\"{saved[\"calls\"]} {saved[\"path\"]}\");"
381+
}
382+
],
372383
"app_type": [
373384
{
374385
"code": "device.Type(\"testid=email\", \"hello@example.com\");"

‎examples/go.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@
204204
"app_map": [
205205
{
206206
"code": "elements, err := dev.Map(ctx)\nif err != nil {\n\treturn err\n}\nfor _, el := range elements {\n\tfmt.Println(el.Ref, el.Role, el.Label)\n}"
207+
},
208+
{
209+
"code": "diff, err := dev.MapDiff(ctx)\nif err != nil {\n\treturn err\n}\nfor _, e := range diff.Added {\n\tfmt.Println(\"+\", e.Ref, e.Label)\n}\nfor _, c := range diff.Changed {\n\tfmt.Println(\"~\", c.After.Ref, c.After.Label, c.What)\n}"
207210
}
208211
],
209212
"app_network": [
@@ -369,6 +372,14 @@
369372
"code": "if err := dev.SetTimezone(ctx, \"Asia/Tokyo\"); err != nil {\n\treturn err\n}"
370373
}
371374
],
375+
"app_trace": [
376+
{
377+
"code": "if _, err := dev.TraceStart(ctx, &mobium.TraceOptions{Name: \"sign in\"}); err != nil {\n\treturn err\n}"
378+
},
379+
{
380+
"code": "saved, err := dev.TraceStop(ctx, \"sign-in.zip\")\nif err != nil {\n\treturn err\n}\nfmt.Println(saved.Calls, saved.Path)"
381+
}
382+
],
372383
"app_type": [
373384
{
374385
"code": "if err := dev.Type(ctx, \"testid=email\", \"hello@example.com\"); err != nil {\n\treturn err\n}"

‎examples/java.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@
204204
"app_map": [
205205
{
206206
"code": "for (Element e : device.map()) {\n System.out.println(e.ref() + \" \" + e.role() + \" \" + e.label());\n}"
207+
},
208+
{
209+
"code": "Map<String, Object> diff = device.mapDiff();\nSystem.out.println(diff.get(\"added\"));\nSystem.out.println(diff.get(\"changed\"));"
207210
}
208211
],
209212
"app_network": [
@@ -369,6 +372,14 @@
369372
"code": "String zone = device.timezone(\"Asia/Tokyo\"); // read back"
370373
}
371374
],
375+
"app_trace": [
376+
{
377+
"code": "device.traceStart(\"sign in\");"
378+
},
379+
{
380+
"code": "Map<String, Object> saved = device.traceStop(\"sign-in.zip\");\nSystem.out.println(saved.get(\"calls\") + \" \" + saved.get(\"path\"));"
381+
}
382+
],
372383
"app_type": [
373384
{
374385
"code": "device.type(\"testid=email\", \"hello@example.com\");"

‎examples/javascript.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@
204204
"app_map": [
205205
{
206206
"code": "const elements = await device.map()\nfor (const e of elements) console.log(e.ref, e.role, e.label)\n// @e1 button Network & internet ..."
207+
},
208+
{
209+
"code": "const diff = await device.mapDiff()\nfor (const e of diff.added) console.log('+', e.ref, e.label)\nfor (const c of diff.changed) console.log('~', c.after.ref, c.after.label, c.what)"
207210
}
208211
],
209212
"app_network": [
@@ -369,6 +372,14 @@
369372
"code": "const zone = await device.timezone('Asia/Tokyo')"
370373
}
371374
],
375+
"app_trace": [
376+
{
377+
"code": "await device.traceStart({ name: 'sign in' })"
378+
},
379+
{
380+
"code": "const saved = await device.traceStop('sign-in.zip')\nconsole.log(saved.calls, saved.path)"
381+
}
382+
],
372383
"app_type": [
373384
{
374385
"code": "await device.type('testid=email', 'hello@example.com')"

‎examples/no-picture.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
"source": "it reads the hierarchy, and nothing on the screen changes.",
2424
"state": "it reads whether an app is running, and nothing on the screen changes.",
2525
"time": "it reads the device's clock, and nothing on the screen changes.",
26+
"trace": "what it keeps is a zip, which opens in the Playwright trace viewer: every step, and the screen after each with the map drawn over it.",
2627
"uninstall": "it removes an app, which shows nowhere on the screen in front."
2728
}

‎examples/python.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@
204204
"app_map": [
205205
{
206206
"code": "for el in device.map():\n print(el.ref, el.label)"
207+
},
208+
{
209+
"code": "diff = device.map_diff()\nfor e in diff[\"added\"]:\n print(\"+\", e.ref, e.label)\nfor c in diff[\"changed\"]:\n print(\"~\", c[\"after\"].ref, c[\"after\"].label, c[\"what\"])"
207210
}
208211
],
209212
"app_network": [
@@ -369,6 +372,14 @@
369372
"code": "device.timezone(\"Asia/Tokyo\")"
370373
}
371374
],
375+
"app_trace": [
376+
{
377+
"code": "device.trace_start(name=\"sign in\")"
378+
},
379+
{
380+
"code": "saved = device.trace_stop(\"sign-in.zip\")\nprint(saved[\"calls\"], saved[\"path\"])"
381+
}
382+
],
372383
"app_type": [
373384
{
374385
"code": "device.type(\"testid=email\", \"hello@example.com\")"

0 commit comments

Comments
 (0)