# TestFly Part 13: Actionability engine, auto-wait and verified click/fill/clear assertions

URL: https://hakangul.lovable.app/blog/testfly-part-13-actionability-engine-auto-wait-verified-actions
Author: Hakan Gül — Team Lead Senior Test Automation Engineer
Published: 2026-10-12
Updated: 2026-10-18
Category: test-automation
Tags: TestFly, Selenium, Java, SDET, Testing

> TestFly 1.1.0 adds a Playwright-style actionability engine. Before every click, hover, type and clear, it waits until the element is visible, enabled, stable and uncovered. The new assertThat(x).click()/.fill()/.clear() methods also verify that the action reached the page and changed it.

## English

TestFly 1.1.0 adds an actionability engine. Every `click`, `hover`, `type`, `clear` and `append` call goes through it before touching the DOM. The engine checks that the element is visible, enabled where that matters, geometrically stable and not covered by another element, and scrolls it into view if needed. On top of that, `assertThat(x).click()` / `.fill(text)` / `.clear()` make the action itself an assertion: they verify that the click event reached the element and that the typed text stayed in the field. When an element never becomes ready, TestFly throws `NotActionableException` with the element and the exact blocker in the message.

## How TestFly decides an element is ready for an action

Every interaction is tagged with an `ActionKind`, which decides which checks apply:

```java
public enum ActionKind {
    CLICK(true, true),   // enabled, and not covered by another element
    HOVER(false, true),  // not covered; a disabled element can still be hovered
    EDIT(true, false);   // enabled; being covered doesn't matter for keyboard input
}
```

Every kind requires the element to be visible and stable, whatever its flags say. `WaitEngine.waitForActionable(element, kind)` polls until all required checks pass. If the element drifts offscreen between polls, it scrolls it back into view:

```java
public static WebElement waitForActionable(WebElement element, ActionKind kind) {
    TestFlyConfig.Actionability cfg = actionabilityConfig();
    if (!cfg.isEnabled()) {
        return kind == ActionKind.CLICK ? waitForClickable(element) : waitForVisible(element);
    }
    // visible, enabled (if required), stable bounding box, not covered (if required)...
}
```

A stale element surfaces as `StaleElementReferenceException`. The caller (the `Locator` chain) then re-resolves it from scratch instead of failing on a detached node.

## What gets checked, and in what order

| Check | Applies to | Detail |
| --- | --- | --- |
| Visible | all kinds | element has a non-empty bounding box and isn't `display:none`/`visibility:hidden` |
| Enabled | `CLICK`, `EDIT` | skipped for `HOVER`; a disabled button can still be hovered |
| Stable | all kinds | bounding box unchanged between two consecutive polls (default poll interval: 100ms) |
| Not covered | `CLICK`, `HOVER` | nothing else receives a hit-test at the element's centre; skipped for `EDIT` |
| Auto-scroll | all kinds | scrolls the element to the viewport centre if it's offscreen when checked |

The `stabilityIntervalMs` setting (default 100ms) is both the polling interval and the minimum time the bounding box must stay put. Playwright uses the same idea to wait out animations; TestFly adapts it to Selenium's `WebElement`.

## What happens when an element never becomes actionable

```java
public class NotActionableException extends TimeoutException {
    public NotActionableException(String message, Throwable cause) {
        super(message, cause);
    }
}
```

It extends `TimeoutException`, so existing `catch (TimeoutException e)` handlers keep working. The message names the element and the specific blocker, for example the overlay covering the centre point, or a bounding box that kept moving. A test never silently clicks the wrong spot or types into a field that is still animating.

## Configuring or bypassing the checks

```yaml
# testfly.yml
actionability:
  enabled: true           # false restores the pre-1.1.0 waits
  stabilityIntervalMs: 100
  hitTargetCheck: true
  autoScroll: true
```

```java
public static final class Actionability {
    private boolean enabled = true;
    private int stabilityIntervalMs = 100;
    private boolean hitTargetCheck = true;
    private boolean autoScroll = true;
}
```

With `actionability.enabled: false`, TestFly falls back to the legacy waits: `waitForClickable` for clicks and `waitForVisible` for everything else. This helps during a migration, or when a page really needs the old behaviour.

For a single locator, `Locator.force()` skips only the stability and not-covered checks (like Playwright's `force: true`). The element still has to be visible, and enabled where the action needs it:

```java
find("#banner-close").force().click();
```

`BasePage.doubleClick`, `rightClick`, `selectBy*` and `BaseConditions.click`/`type` all go through the same `waitForActionable` call, so the behaviour is the same across the whole API.

## How `assertThat(x).click()` verifies that a click landed

A plain `Locator.click()` runs the actionability wait and clicks, as before. `assertThat(x).click()` also turns the action into an assertion:

```java
assertThat(loginButton).click();
```

1. It resolves the element the same way `Locator.click()` does, including self-healing, and waits until it is visible and enabled.
2. It scrolls the element to the centre of the viewport and moves the mouse onto it with `Actions`, as a real user would.
3. It waits until nothing else covers the element's centre point, such as a cookie banner, a modal or a sticky header.
4. It clicks, then asserts that the `click` event reached the element or one of its descendants.

On success it logs a passed `Clicked: ...` step. On failure you get a regular `AssertionError` (or a recorded soft failure in soft mode) that names the step that failed. If the click navigates away or opens an alert before the event listener can report back, the click still counts as delivered, so a page that moves on does not cause a failure. `Locator.click()` itself has not changed; this is an additional, stricter method on `LocatorAssert`.

## How `assertThat(x).fill(text)` and `.clear()` verify the field changed

```java
assertThat(userNameField).fill("admin");
assertThat(passwordField).fill(password);
assertThat(searchField).clear();
```

Both use the same path (`fillAndVerify`):

1. Resolve the element as `Locator.fill(String)` would (waiting, with self-healing) and wait until it is visible and enabled.
2. Wait until the field is not `readonly`, then scroll it to the viewport centre.
3. Clear it and type the text exactly as `Locator.type(String)` does.
4. Wait until the field's value equals the text and stays that way. This catches cases where `maxlength`, an input mask or framework state (React, Vue…) silently changed or reset what was typed.

`clear()` is the same path with an empty string. For `type="password"` fields, the value is never logged or put in a failure message; only its length is. Fields that reformat input while you type, such as phone masks, will fail this stricter assertion. For those, use `Locator.fill(text)` followed by `assertThat(x).hasValue(formattedValue)`.

## FAQ

### Does turning on actionability checks slow every test down?

Each action waits about one extra polling interval (100ms by default) compared with the pre-1.1.0 waits, because the engine needs at least two consecutive stable polls to confirm the bounding box has stopped moving. When JavaScript is unavailable the checks fail open, so the session does not have to support JS.

### Does `assertThat(x).click()` replace `Locator.click()`?

No. `Locator.click()` is unchanged and still only runs the actionability wait and clicks. `assertThat(x).click()` is a separate, verified method. It also asserts that the click event reached the element, logs a `Clicked: ...` step, and supports `as(...)`, `within(...)` and soft mode.

### Can I combine `not()` with the verified `click()`/`fill()`/`clear()`?

No. These three methods call `rejectNegation(...)` and throw if `not()` was chained before them. They assert that an action happened and changed the page in a way that can be checked, and a "negated click" has no clear meaning.

### What's the difference between `force()` and `actionability.enabled: false`?

`force()` works per locator and skips only the stability and not-covered checks; the element must still be visible, and enabled where the action requires it. `actionability.enabled: false` is global. It reverts every action in the suite to the pre-1.1.0 waits (`waitForClickable`/`waitForVisible`) and drops all the new checks at once.

## Türkçe

TestFly 1.1.0 ile birlikte bir actionability (eyleme hazırlık) motoru geldi. Her `click`, `hover`, `type`, `clear` ve `append` çağrısı DOM'a dokunmadan önce bu motordan geçiyor. Motor elementin görünür olduğunu, gerekiyorsa etkin (enabled) olduğunu, geometrik olarak sabit durduğunu ve üstünü başka bir elementin kapatmadığını kontrol ediyor, gerekirse elementi görünür alana kaydırıyor. Bunun üstüne `assertThat(x).click()` / `.fill(text)` / `.clear()` eylemin kendisini assertion'a çeviriyor: click olayının gerçekten elemente ulaştığını ve yazılan metnin alanda kaldığını doğruluyor. Element hiç hazır hale gelmezse `NotActionableException` fırlatılıyor ve mesajda element ile onu engelleyen neden açıkça yazıyor.

## TestFly bir elementin eyleme hazır olduğuna nasıl karar veriyor

Her etkileşim bir `ActionKind` ile etiketleniyor. Hangi kontrollerin uygulanacağını bu değer belirliyor:

```java
public enum ActionKind {
    CLICK(true, true),   // etkin olmalı, ve başka bir eleman tarafından kapatılmamalı
    HOVER(false, true),  // kapatılmamalı; devre dışı bir eleman yine de hover edilebilir
    EDIT(true, false);   // etkin olmalı; kapatılmış olması klavye girişi için önemli değil
}
```

Bayraklar ne olursa olsun her tür için elementin görünür ve sabit olması gerekiyor. `WaitEngine.waitForActionable(element, kind)` gerekli kontrollerin hepsi geçene kadar polling yapıyor. Element iki polling arasında ekran dışına kayarsa onu tekrar görünür alana kaydırıyor:

```java
public static WebElement waitForActionable(WebElement element, ActionKind kind) {
    TestFlyConfig.Actionability cfg = actionabilityConfig();
    if (!cfg.isEnabled()) {
        return kind == ActionKind.CLICK ? waitForClickable(element) : waitForVisible(element);
    }
    // görünür, etkin (gerekiyorsa), sabit bounding box, kapatılmamış (gerekiyorsa)...
}
```

Stale olmuş (DOM'dan kopmuş) bir element `StaleElementReferenceException` olarak yukarı iletiliyor. Böylece çağıran taraf (`Locator` zinciri) kopmuş düğüm yüzünden hata vermek yerine elementi baştan çözebiliyor.

## Neler, hangi sırayla kontrol ediliyor

| Kontrol | Uygulandığı tür | Detay |
| --- | --- | --- |
| Görünür | tüm türler | element boş olmayan bir bounding box'a sahip ve `display:none`/`visibility:hidden` değil |
| Etkin | `CLICK`, `EDIT` | `HOVER` için atlanır; devre dışı bir buton yine de hover edilebilir |
| Sabit | tüm türler | ardışık iki pollingde bounding box değişmemiş (varsayılan polling aralığı: 100ms) |
| Kapatılmamış | `CLICK`, `HOVER` | elementin merkezinde başka hiçbir şey hit-test'i almıyor; `EDIT` için atlanır |
| Otomatik kaydırma | tüm türler | kontrol sırasında ekran dışındaysa elementi viewport merkezine kaydırır |

`stabilityIntervalMs` ayarı (varsayılan 100ms) hem polling aralığı hem de bounding box'ın yerinden oynamadan durması gereken en kısa süre. Playwright animasyonların bitmesini beklemek için aynı yöntemi kullanıyor, TestFly da bunu Selenium'un `WebElement`'ine uyarlıyor.

## Element hiç eyleme hazır olmazsa ne oluyor

```java
public class NotActionableException extends TimeoutException {
    public NotActionableException(String message, Throwable cause) {
        super(message, cause);
    }
}
```

`TimeoutException`'dan türediği için mevcut `catch (TimeoutException e)` blokları aynen çalışmaya devam ediyor. Mesajda element ve onu engelleyen neden yazıyor, örneğin merkez noktayı hangi overlay'in kapattığı ya da bounding box'ın durmadan hareket ettiği. Böylece test sessizce yanlış yere tıklamıyor, animasyonu bitmemiş bir alana da yazmıyor.

## Kontrolleri yapılandırmak veya atlamak

```yaml
# testfly.yml
actionability:
  enabled: true           # false, 1.1.0 öncesi bekleme davranışını geri getirir
  stabilityIntervalMs: 100
  hitTargetCheck: true
  autoScroll: true
```

```java
public static final class Actionability {
    private boolean enabled = true;
    private int stabilityIntervalMs = 100;
    private boolean hitTargetCheck = true;
    private boolean autoScroll = true;
}
```

`actionability.enabled: false` verildiğinde eski bekleme davranışına dönülüyor: click için `waitForClickable`, geri kalan her şey için `waitForVisible`. Geçiş sürecinde ya da bir sayfa gerçekten eski davranışı gerektirdiğinde bu işe yarıyor.

Tek bir locator için `Locator.force()` yalnızca sabitlik ve üstü kapalı olma kontrollerini atlıyor (Playwright'taki `force: true` gibi). Elementin görünür olması, eylem gerektiriyorsa etkin olması yine şart:

```java
find("#banner-close").force().click();
```

`BasePage.doubleClick`, `rightClick`, `selectBy*` ve `BaseConditions.click`/`type` da aynı `waitForActionable` çağrısını kullanıyor, dolayısıyla davranış API'nin her yerinde aynı.

## `assertThat(x).click()` tıklamanın gerçekten ulaştığını nasıl doğruluyor

Düz `Locator.click()` eskisi gibi actionability beklemesini yapıp tıklıyor. `assertThat(x).click()` ise eylemi bir assertion'a çeviriyor:

```java
assertThat(loginButton).click();
```

1. Elementi `Locator.click()` ile aynı şekilde (self-healing dahil) çözüyor, görünür ve etkin olana kadar bekliyor.
2. Elementi viewport'un ortasına kaydırıyor ve gerçek bir kullanıcı gibi `Actions` ile fareyi üstüne getiriyor.
3. Merkez noktasının üstünde çerez banner'ı, modal ya da yapışkan header gibi başka bir şey kalmayana kadar bekliyor.
4. Tıklıyor, ardından `click` olayının elemente ya da alt elementlerinden birine gerçekten ulaştığını assert ediyor.

Başarılı olursa `Clicked: ...` adımı geçti olarak loglanıyor. Başarısız olursa hangi adımda takıldığını söyleyen normal bir `AssertionError` alıyorsunuz (soft modda ise kaydedilmiş bir soft failure). Tıklama, olay dinleyicisi sonucu okuyamadan sayfayı değiştirir ya da bir alert açarsa yine ulaşmış sayılıyor; sayfanın başka yere geçmesi testi düşürmüyor. `Locator.click()` olduğu gibi kaldı, bu metot `LocatorAssert`'e eklenmiş daha katı bir seçenek.

## `assertThat(x).fill(text)` ve `.clear()` alanın değiştiğini nasıl doğruluyor

```java
assertThat(userNameField).fill("admin");
assertThat(passwordField).fill(password);
assertThat(searchField).clear();
```

İkisi de aynı yolu (`fillAndVerify`) kullanıyor:

1. Elementi `Locator.fill(String)` gibi (bekleyerek ve self-healing ile) çözüyor, görünür ve etkin olana kadar bekliyor.
2. Alan `readonly` olmaktan çıkana kadar bekliyor, sonra viewport'un ortasına kaydırıyor.
3. Alanı temizleyip metni `Locator.type(String)` ile birebir aynı şekilde yazıyor.
4. Alanın değeri metne eşit olana ve öyle kalana kadar bekliyor. `maxlength`, input mask ya da framework state'i (React, Vue…) yazılanı sessizce değiştirir veya sıfırlarsa bu adımda yakalanıyor.

`clear()` aynı yolu boş string ile çalıştırıyor. `type="password"` alanlarında değer hiçbir zaman loga ya da hata mesajına yazılmıyor, yalnızca uzunluğu yazılıyor. Telefon maskesi gibi yazarken girişi yeniden biçimlendiren alanlar bu katı assertion'dan geçemez. Bu alanlarda `Locator.fill(text)` kullanıp ardından `assertThat(x).hasValue(formatlanmışDeğer)` ile kontrol edin.

## SSS

### Actionability kontrollerini açmak testleri yavaşlatır mı?

Her eylem, 1.1.0 öncesindeki beklemelere göre yaklaşık bir polling aralığı (varsayılan 100ms) daha fazla bekliyor, çünkü motorun bounding box'ın durduğunu doğrulaması için art arda en az iki sabit polling görmesi gerekiyor. JavaScript kullanılamıyorsa kontroller fail-open çalışıyor, yani oturumun JS desteklemesi zorunlu değil.

### `assertThat(x).click()`, `Locator.click()`'in yerini mi alıyor?

Hayır. `Locator.click()` değişmedi, hâlâ sadece actionability beklemesini yapıp tıklıyor. `assertThat(x).click()` buna ek olarak gelen, doğrulama yapan ayrı bir metot. Click olayının elemente ulaştığını da assert ediyor, `Clicked: ...` adımını logluyor, `as(...)`, `within(...)` ve soft modu destekliyor.

### `not()`'u doğrulanmış `click()`/`fill()`/`clear()` ile birlikte kullanabilir miyim?

Hayır. Bu üç metot `rejectNegation(...)` çağırıyor ve öncesinde `not()` zincirlenmişse hata fırlatıyor. Bir eylemin gerçekleştiğini ve sayfayı doğrulanabilir biçimde değiştirdiğini assert ediyorlar, "negatif tıklama"nın da tutarlı bir tanımı yok.

### `force()` ile `actionability.enabled: false` arasındaki fark ne?

`force()` locator bazında çalışıyor ve yalnızca sabitlik ve üstü kapalı olma kontrollerini atlıyor; element yine görünür, eylem gerektiriyorsa etkin olmalı. `actionability.enabled: false` ise global. Suite'teki tüm eylemleri 1.1.0 öncesi beklemelere (`waitForClickable`/`waitForVisible`) döndürüyor ve yeni kontrollerin hepsini birden devre dışı bırakıyor.
