Zum Hauptinhalt springen

Einen UI-Snapshot abrufen (ui_element.snapshot)

Diese Funktion ist erst in Versionen nach 20260507 verfügbar.

Deklaration

Snapshot, Fehlermeldung = ui_element.snapshot([ Optionen ])

Parameter

Rückgabewert

  • Snapshot Tabellenwert; enthält die aktuelle Liste der UI-Elemente und Snapshot-Methoden. Bei einem Fehler nil.
  • Fehlermeldung Textwert; Fehlerursache.

Snapshot-Methoden

Element = Snapshot:find(Selektor)
Elementliste = Snapshot:find_all(Selektor)
Status, Information = Snapshot:click(Selektor_oder_Element [, Optionen ])
Status, Information = Snapshot:scroll([ Selektor_oder_Element, ] Richtung [, Optionen ])
Status, Information = Snapshot:input_text(Selektor_oder_Element, Text [, Optionen ])
Status, Information = Snapshot:set_text(Selektor_oder_Element, Text [, Optionen ])
Status, Information = Snapshot:clear_text(Selektor_oder_Element [, Optionen ])
Status, Information = Snapshot:toggle(Selektor_oder_Element [, Optionen ])
Status, Information = Snapshot:set_checked(Selektor_oder_Element, Auswahlstatus [, Optionen ])
Status, Information = Snapshot:set_value(Selektor_oder_Element, Wert [, Optionen ])
Status, Information = Snapshot:increase(Selektor_oder_Element [, Optionen ])
Status, Information = Snapshot:decrease(Selektor_oder_Element [, Optionen ])

Hinweise

Ein Snapshot ist ein einmaliges Ergebnis und eignet sich für mehrere Suchvorgänge oder aufeinanderfolgende Aktionen innerhalb derselben Oberfläche. Nach einem Seitenwechsel, einem Dialog, einem Scrollvorgang oder einer Inhaltsaktualisierung sollte snapshot() erneut aufgerufen werden. Häufige Felder einer Snapshottabelle sind elements und count.

Beispiel

local ui_element = require("ui_element")

local ui, err = ui_element.snapshot({
max_level = 2,
})

if ui then
local search = ui:find({
title = "搜索",
role = "text_field",
})
if search then
ui:set_text(search, "XXTouch")
end
else
sys.toast(err)
end

Hinweis: Der obige Code verwendet die Funktion sys.toast aus einem anderen Kapitel.