Class ElementResolver

java.lang.Object
com.codeborne.selenide.mcp.ElementResolver

public class ElementResolver extends Object
Parses selector strings into Selenium By locators.

Supported selector formats:

  • CSS selectors: #id, .class, tag.class, input[type=email]
  • XPath: strings starting with // or ./
  • Text: text=Sign In (exact text match)
  • Attribute shorthand: data-test-id=submit, data-testid=submit, name=email

Limitation: attribute shorthand detection uses a heuristic — the part before = must match [a-zA-Z][a-zA-Z0-9-]* and the selector must not contain [. Complex CSS selectors with = (e.g. div>input[type=text]) are handled correctly because they contain [, but unusual edge cases may be misidentified.

  • Constructor Details

    • ElementResolver

      public ElementResolver()
  • Method Details

    • resolve

      public org.openqa.selenium.By resolve(String selector)