Skip to content

Click on element generates System.ArgumentException #146

@PiotrNestor

Description

@PiotrNestor

For a Java Eclipse SWT based desktop application, for some element types it's not possible to preform element click.

The driver generates:
System.ArgumentException: Value does not fall within the expected range.
which is thrown by the Interop.UIAutomationClient.IUIAutomationScrollItemPattern.ScrollIntoView() method.

In this case it works to click on the element coordinates. Example:

new Actions((WebDriver)Context.getDriver()).moveToElement(e).click().perform();

What's causing the problem?

Example driver log for the exception:

      Request starting HTTP/1.1 POST http://localhost:4723/session/bf1d8a1c-de9e-4909-9d06-2811c766186e/element/d15bb379-d340-43fb-af36-cbf32940914e/click - application/json;+charset=utf-8 50
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'FlaUI.WebDriver.Controllers.ElementController.ElementClick (FlaUI.WebDriver)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102]
      Route matched with {action = "ElementClick", controller = "Element"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.ActionResult] ElementClick(System.String, System.String) on controller FlaUI.WebDriver.Controllers.ElementController (FlaUI.WebDriver).
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[105]
      Executed action FlaUI.WebDriver.Controllers.ElementController.ElementClick (FlaUI.WebDriver) in 2.0294ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'FlaUI.WebDriver.Controllers.ElementController.ElementClick (FlaUI.WebDriver)'
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.ArgumentException: Value does not fall within the expected range.
         at Interop.UIAutomationClient.IUIAutomationScrollItemPattern.ScrollIntoView()
         at FlaUI.UIA3.Patterns.ScrollItemPattern.<ScrollIntoView>b__2_0()
         at FlaUI.Core.Tools.Com.Call(Action nativeAction)
         at FlaUI.UIA3.Patterns.ScrollItemPattern.ScrollIntoView()
         at FlaUI.WebDriver.Controllers.ElementController.ScrollElementContainerIntoView(AutomationElement element)
         at FlaUI.WebDriver.Controllers.ElementController.ElementClick(String sessionId, String elementId)
         at lambda_method45(Closure, Object)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'FlaUI.WebDriver.Controllers.ErrorController.HandleError (FlaUI.WebDriver)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102]
      Route matched with {action = "HandleError", controller = "Error"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult HandleError() on controller FlaUI.WebDriver.Controllers.ErrorController (FlaUI.WebDriver).
fail: FlaUI.WebDriver.Controllers.ErrorController[0]
      Returning WebDriver error response with error code 'unknown error'
      System.ArgumentException: Value does not fall within the expected range.
         at Interop.UIAutomationClient.IUIAutomationScrollItemPattern.ScrollIntoView()
         at FlaUI.UIA3.Patterns.ScrollItemPattern.<ScrollIntoView>b__2_0()
         at FlaUI.Core.Tools.Com.Call(Action nativeAction)
         at FlaUI.UIA3.Patterns.ScrollItemPattern.ScrollIntoView()
         at FlaUI.WebDriver.Controllers.ElementController.ScrollElementContainerIntoView(AutomationElement element)
         at FlaUI.WebDriver.Controllers.ElementController.ElementClick(String sessionId, String elementId)
         at lambda_method45(Closure, Object)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions