Skip to content

Using Selenium.WebDriver's By.Id for finding elements fails when the ID starts with a numeral #138

@ChristoWolf

Description

@ChristoWolf

Hi!

I have followed your Getting Started, but having troubles with finding existing elements using Selenium.WebDriver's By.Id.
I have not tried any other selector strategies yet.
The session that I am using is tied to the Root app.

Here is the exception thrown by OpenQA.Selenium.WebDriver.FindElement:

Exception thrown: 'OpenQA.Selenium.UnsupportedOperationException' in System.Private.CoreLib.dll: 'Selector strategy 'css selector' with value '#\34 b090d48-e3a5-4eb4-bd37-4bd62dfa6e5b' is not supported'
   at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
   at OpenQA.Selenium.WebDriver.<ExecuteAsync>d__63.MoveNext()
   at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebDriver.FindElement(String mechanism, String value)
   at OpenQA.Selenium.By.<.ctor>b__11_0(ISearchContext context)
   at OpenQA.Selenium.By.FindElement(ISearchContext context)
   at OpenQA.Selenium.WebDriver.FindElement(By by)

The FlaUI.WebDriver output reads:

info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 POST http://127.0.0.1:4723/session/33131d2d-ee74-4618-a2cc-9cfcfe019e86/element - application/json;+charset=utf-8 76
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'FlaUI.WebDriver.Controllers.FindElementsController.FindElement (FlaUI.WebDriver)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102]
      Route matched with {action = "FindElement", controller = "FindElements"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.ActionResult] FindElement(System.String, FlaUI.WebDriver.Models.FindElementRequest) on controller FlaUI.WebDriver.Controllers.FindElementsController (FlaUI.WebDriver).
fail: FlaUI.WebDriver.WebDriverResponseExceptionFilter[0]
      Returning WebDriver error response with error code 'unsupported operation'
      FlaUI.WebDriver.WebDriverResponseException: Selector strategy 'css selector' with value '#\34 b090d48-e3a5-4eb4-bd37-4bd62dfa6e5b' is not supported
         at FlaUI.WebDriver.Services.ConditionParser.ParseCondition(ConditionFactory conditionFactory, String using, String value)
         at FlaUI.WebDriver.Controllers.FindElementsController.FindElementFrom(Func`1 startNode, FindElementRequest findElementRequest, Session session)
         at FlaUI.WebDriver.Controllers.FindElementsController.FindElement(String sessionId, FindElementRequest findElementRequest)
         at lambda_method14(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)
info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
      Executing ObjectResult, writing value of type 'FlaUI.WebDriver.Models.ResponseWithValue`1[[FlaUI.WebDriver.Models.ErrorResponse, FlaUI.WebDriver, Version=0.3.3.0, Culture=neutral, PublicKeyToken=null]]'.
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[105]
      Executed action FlaUI.WebDriver.Controllers.FindElementsController.FindElement (FlaUI.WebDriver) in 0.9177ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'FlaUI.WebDriver.Controllers.FindElementsController.FindElement (FlaUI.WebDriver)'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 POST http://127.0.0.1:4723/session/33131d2d-ee74-4618-a2cc-9cfcfe019e86/element - 500 - application/json;+charset=utf-8 1.0363ms

4b090d48-e3a5-4eb4-bd37-4bd62dfa6e5b is the actual automation ID that I'm looking for, so I am confused by the leading 4 being escaped to #\34 by the Selenium client.

In any case, even if that ID would not exist, it is weird that FlaUI.WebDriver says that it does not support the CSS selector.

Used versions:

  • FlaUI.WebDriver v0.3.3
  • Selenium.WebDriver v4.29.0, also tried with v4.21.0
  • The client code is wrapped on our side in .NET Standard 2.0 code.

Thanks for any help!

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