Getting Data
Alumnium can retrieve data from a web page when you instruct it to get something. It analyzes the current information on the web page, 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")
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") == 4
Specific Data
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"]
Typecasting
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
:
Vision
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)
Flakiness
Alumnium automatically waits for the following conditions before attempting to extract any data:
- The HTML document is loaded and ready.
- Resources on the page are loaded.
- Document mutations are finished.
- XHR/fetch requests are finished.