# GeeTest slider

> How to send a GeeTest slider challenge and how to use the answer, an offset as a percentage of the background width.

Use `geetest` for the puzzle slider of GeeTest. You get the offset to drag the piece to.


- [Create a GeeTest job](https://solvecha.com/docs/api/create-geetest-job.md): The endpoint with all fields and error codes.


## What to send

| Field | Meaning |
|---|---|
| `task` | The instruction text of the challenge, for example `slide`. |
| `image_data` | One complete challenge screenshot, or two pictures in this order: the background, then the transparent puzzle piece. |

```json
{
  "task": "slide",
  "image_data": ["BASE64_BACKGROUND", "BASE64_PIECE"]
}
```

## What you get

An object with `x`: the offset as a percentage of the width of the background image.

```json
{"data": {"x": 42.5}}
```

## Use the offset

Convert the percentage into pixels with the width of the background as the page shows it, then move the slider handle by that distance. This sketch uses Playwright. Replace the two selectors with the ones of your page, because GeeTest changes its markup.

```js
const x = answer.data.x; // 42.5
const bg = await page.locator("BACKGROUND_SELECTOR").boundingBox();
const distance = (bg.width * x) / 100;

const handle = await page.locator("HANDLE_SELECTOR").boundingBox();
const startX = handle.x + handle.width / 2;
const startY = handle.y + handle.height / 2;
await page.mouse.move(startX, startY);
await page.mouse.down();
await page.mouse.move(startX + distance, startY, { steps: 25 });
await page.mouse.up();
```
