From 8d146c6194b61d1b9ccabc26bcb94fe0ecf6f111 Mon Sep 17 00:00:00 2001 From: Christian Bromann Date: Mon, 12 Feb 2024 10:00:36 -0800 Subject: [PATCH] (fix): guard element calls - refs https://github.com/webdriverio/expect-webdriverio/commit/95d97bd98460b03cf5cf2541bed24aa46236fb0e#r138469988 --- src/matchers/element/toBeClickable.ts | 2 +- src/matchers/element/toBeDisplayed.ts | 2 +- src/matchers/element/toBeDisplayedInViewport.ts | 2 +- src/matchers/element/toBeEnabled.ts | 2 +- src/matchers/element/toBeExisting.ts | 2 +- src/matchers/element/toBeFocused.ts | 2 +- src/matchers/element/toBeSelected.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/matchers/element/toBeClickable.ts b/src/matchers/element/toBeClickable.ts index 28c0ce92..9224c109 100644 --- a/src/matchers/element/toBeClickable.ts +++ b/src/matchers/element/toBeClickable.ts @@ -12,7 +12,7 @@ export async function toBeClickable( options, }) - const result = await executeCommandBe.call(this, received, el => el.isClickable(), options) + const result = await executeCommandBe.call(this, received, el => el?.isClickable(), options) await options.afterAssertion?.({ matcherName: 'toBeClickable', diff --git a/src/matchers/element/toBeDisplayed.ts b/src/matchers/element/toBeDisplayed.ts index 1e34c475..ae27eb05 100644 --- a/src/matchers/element/toBeDisplayed.ts +++ b/src/matchers/element/toBeDisplayed.ts @@ -13,7 +13,7 @@ export async function toBeDisplayed( options, }) - const result = await executeCommandBe.call(this, received, el => el.isDisplayed(), options) + const result = await executeCommandBe.call(this, received, el => el?.isDisplayed(), options) await options.afterAssertion?.({ matcherName: 'toBeDisplayed', diff --git a/src/matchers/element/toBeDisplayedInViewport.ts b/src/matchers/element/toBeDisplayedInViewport.ts index e692fbcd..c52956c3 100644 --- a/src/matchers/element/toBeDisplayedInViewport.ts +++ b/src/matchers/element/toBeDisplayedInViewport.ts @@ -12,7 +12,7 @@ export async function toBeDisplayedInViewport( options, }) - const result = await executeCommandBe.call(this, received, el => el.isDisplayedInViewport(), options) + const result = await executeCommandBe.call(this, received, el => el?.isDisplayedInViewport(), options) await options.afterAssertion?.({ matcherName: 'toBeDisplayedInViewport', diff --git a/src/matchers/element/toBeEnabled.ts b/src/matchers/element/toBeEnabled.ts index a2bc877b..c98a7483 100644 --- a/src/matchers/element/toBeEnabled.ts +++ b/src/matchers/element/toBeEnabled.ts @@ -12,7 +12,7 @@ export async function toBeEnabled( options, }) - const result = await executeCommandBe.call(this, received, el => el.isEnabled(), options) + const result = await executeCommandBe.call(this, received, el => el?.isEnabled(), options) await options.afterAssertion?.({ matcherName: 'toBeEnabled', diff --git a/src/matchers/element/toBeExisting.ts b/src/matchers/element/toBeExisting.ts index 88d2f90b..4bdb64d0 100644 --- a/src/matchers/element/toBeExisting.ts +++ b/src/matchers/element/toBeExisting.ts @@ -14,7 +14,7 @@ export async function toExist( options, }) - const result = await executeCommandBe.call(this, received, el => el.isExisting(), options) + const result = await executeCommandBe.call(this, received, el => el?.isExisting(), options) await options.afterAssertion?.({ matcherName: 'toExist', diff --git a/src/matchers/element/toBeFocused.ts b/src/matchers/element/toBeFocused.ts index b74fc8cb..def9acfc 100644 --- a/src/matchers/element/toBeFocused.ts +++ b/src/matchers/element/toBeFocused.ts @@ -12,7 +12,7 @@ export async function toBeFocused( options, }) - const result = await executeCommandBe.call(this, received, el => el.isFocused(), options) + const result = await executeCommandBe.call(this, received, el => el?.isFocused(), options) await options.afterAssertion?.({ matcherName: 'toBeFocused', diff --git a/src/matchers/element/toBeSelected.ts b/src/matchers/element/toBeSelected.ts index 6bfefda5..5b5cdd68 100644 --- a/src/matchers/element/toBeSelected.ts +++ b/src/matchers/element/toBeSelected.ts @@ -12,7 +12,7 @@ export async function toBeSelected( options, }) - const result = await executeCommandBe.call(this, received, el => el.isSelected(), options) + const result = await executeCommandBe.call(this, received, el => el?.isSelected(), options) await options.afterAssertion?.({ matcherName: 'toBeSelected',