---
title: Getting Data
description: Learn how Alumnium retrieves data from applications with AI. Ensure test accuracy by checking the data directly.
---

import LanguageContent from "../../../../components/LanguageContent.astro";

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:

<LanguageContent lang="java">

```java
al.get("number of pending tasks");
```

</LanguageContent>

<LanguageContent lang="python">

```python
al.get("number of pending tasks")
```

</LanguageContent>

<LanguageContent lang="typescript">

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

</LanguageContent>

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

<video
  class="rounded-xl"
  alt="A screen recording of Alumnium getting number of pending tasks"
  controls
  controlslist="nofullscreen"
  disablepictureinpicture
  muted
  playsinline
  width="100%"
  height="auto"
>
  <source src="/videos/get-int.mp4" type="video/mp4" />
  <source src="/videos/get-int.webm" type="video/webm" />
</video>

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

<LanguageContent lang="java">

```java
assertEquals(2L, al.get("number of pending tasks"));
```

</LanguageContent>

<LanguageContent lang="python">

```python
assert al.get("number of pending tasks") == 2
```

</LanguageContent>

<LanguageContent lang="typescript">

```typescript
expect(await al.get("number of pending tasks")).toBe(2);
```

</LanguageContent>

## Specific Data

Similarly to [actions][1] and [verifications][2], 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.

<LanguageContent lang="java">

```java
assertEquals(
  List.of("buy milk", "buy bread", "buy honey", "buy water"),
  al.get("titles of tasks")
);
assertEquals(
  List.of("buy milk", "buy bread"),
  al.get("titles of complete tasks")
);
assertEquals(
  List.of("buy honey", "buy water"),
  al.get("titles of pending tasks")
);
```

</LanguageContent>

<LanguageContent lang="python">

```python
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"]
```

</LanguageContent>

<LanguageContent lang="typescript">

```typescript
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",
]);
```

</LanguageContent>

<video
  class="rounded-xl"
  alt="A screen recording of Alumnium getting number of pending tasks"
  controls
  controlslist="nofullscreen"
  disablepictureinpicture
  muted
  playsinline
  width="100%"
  height="auto"
>
  <source src="/videos/get-list.mp4" type="video/mp4" />
  <source src="/videos/get-list.webm" type="video/webm" />
</video>

## 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.

<LanguageContent lang="java">
You might need to further typecast returned value if you plan to store it in a variable.

</LanguageContent>

<LanguageContent lang="typescript">
You might need to further typecast returned value if you plan to store it in a variable.

</LanguageContent>

If the data is not present on the page, Alumnium returns a string with explanation why it cannot retrieve the data.

## Vision

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

<LanguageContent lang="java">

```java
al.get("number of pending tasks", new Alumni.GetOptions().withVision(true));
```

</LanguageContent>

<LanguageContent lang="python">

```python
al.get("number of pending tasks", vision=True)
```

</LanguageContent>

<LanguageContent lang="typescript">

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

</LanguageContent>

## Flakiness

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.

[1]: /docs/guides/actions#specific-instructions
[2]: /docs/guides/verifications#specific-verifications
[3]: /docs/guides/verifications#vision
