Skip to content
GitHubDiscordSlack

Getting Data

Alumnium can retrieve data from an application when you instruct it to get something. It analyzes the current information on the mobile or web application, optionally including a screenshot, and extracts the appropriate data.

For example, after creating and completing tasks in the To-Do application, you might want to get the number of pending tasks:

al.get("number of pending tasks")
await al.get("number of pending tasks");

Alumnium checks how many tasks are present on the page, which of them are pending, and then provides a count.

You can then use the number to perform assertions within your test.

assert al.get("number of pending tasks") == 2
expect(await al.get("number of pending tasks")).toBe(2);

Similarly to actions and verifications, Alumnium works better when the extract data requests are concrete.

For example, you might want to separate the retrieval of titles for pending tasks from the retrieval of titles for completed tasks.

assert al.get("titles of tasks") == ["buy milk", "buy bread", "buy honey", "buy water"]
assert al.get("titles of complete tasks") == ["buy milk", "buy bread"]
assert al.get("titles of pending tasks") == ["buy honey", "buy water"]
expect(await al.get("titles of tasks")).toEqual(["buy milk", "buy bread", "buy honey", "buy water"]);
expect(await al.get("titles of complete tasks")).toEqual(["buy milk", "buy bread"]);
expect(await al.get("titles of pending tasks")).toEqual(["buy honey", "buy water"]);

Alumnium attempts to cast the data to an appropriate type. The currently supported types are integer, float, boolean, string, and lists of these types.

If the data is not present on the page, Alumnium returns None:

You might need to further typecast returned value if you plan to store it in a variable.

If the data is not present on the page, Alumnium returns null:

Retrieving data from screenshots works similarly to verifications. In this case, the accessibility tree is completely ignored and therefore does not influence the results.

al.get("number of pending tasks", vision=True)
await al.get("number of pending tasks", { vision: true });

Alumnium automatically waits for the following conditions before attempting to extract any data:

  1. The HTML document is loaded and ready.
  2. Resources on the page are loaded.
  3. Document mutations are finished.
  4. XHR/fetch requests are finished.