Skip to content

Commit 146cac8

Browse files
committed
Check that IsOffscreen is supported.
Check that IsOffscreen is supported before trying to use it. Avalonia 11.0.x does not currently implement this property: I will add it soon but in the meantime check that the property is supported before trying to read it. WinAppDriver seemed to handle this case so FlaUI.WebDriver also should.
1 parent e8a1046 commit 146cac8

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/FlaUI.WebDriver/Controllers/ElementController.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ public async Task<ActionResult> IsElementDisplayed([FromRoute] string sessionId,
3737
{
3838
var session = GetActiveSession(sessionId);
3939
var element = GetElement(session, elementId);
40-
return await Task.FromResult(WebDriverResult.Success(!element.IsOffscreen));
40+
41+
if (element.Properties.IsOffscreen.IsSupported)
42+
{
43+
return await Task.FromResult(WebDriverResult.Success(!element.IsOffscreen));
44+
}
45+
else
46+
{
47+
return await Task.FromResult(WebDriverResult.Success(true));
48+
}
4149
}
4250

4351
[HttpGet("{elementId}/enabled")]
@@ -63,10 +71,15 @@ public async Task<ActionResult> ElementClick([FromRoute] string sessionId, [From
6371
var element = GetElement(session, elementId);
6472

6573
ScrollElementContainerIntoView(element);
66-
if (!await Wait.Until(() => !element.IsOffscreen, session.ImplicitWaitTimeout))
74+
75+
if (element.Properties.IsOffscreen.IsSupported)
6776
{
68-
return ElementNotInteractable(elementId);
77+
if (!await Wait.Until(() => !element.IsOffscreen, session.ImplicitWaitTimeout))
78+
{
79+
return ElementNotInteractable(elementId);
80+
}
6981
}
82+
7083
element.Click();
7184

7285
return WebDriverResult.Success();
@@ -179,9 +192,13 @@ public async Task<ActionResult> ElementSendKeys([FromRoute] string sessionId, [F
179192
var element = GetElement(session, elementId);
180193

181194
ScrollElementContainerIntoView(element);
182-
if (!await Wait.Until(() => !element.IsOffscreen, session.ImplicitWaitTimeout))
195+
196+
if (element.Properties.IsOffscreen.IsSupported)
183197
{
184-
return ElementNotInteractable(elementId);
198+
if (!await Wait.Until(() => !element.IsOffscreen, session.ImplicitWaitTimeout))
199+
{
200+
return ElementNotInteractable(elementId);
201+
}
185202
}
186203

187204
element.Focus();

0 commit comments

Comments
 (0)