So, I've been wanting to take a look at the dotNet code for the different locator strategies (Id, ClassName, XPath, TagName, ...).

In the By class, I've found this for Id:

by.findElementMethod = (ISearchContext context) => ((IFindsById)context).FindElementById(idToFind);
by.findElementsMethod = (ISearchContext context) => ((IFindsById)context).FindElementsById(idToFind);

The interface is here, but that's only the method signature of course. Searching the project doesn't yield any other results.

Where is the actual implementation?

  • Is RemoteDriver what you're looking for? It looks like all the strategies/mechanisms go through the FindElement method and ultimately sent to the server.
    – heenenee
    Commented Apr 7, 2016 at 6:47
  • Hmm... so the actual code to locate an element (e.g. by PartialLinkText) is defined in the specific browser drivers?
    – FDM
    Commented Apr 7, 2016 at 7:41

1 Answer 1


It looks like the different C# browser drivers all extend RemoteDriver and end up sending the find elements commands over HTTP using the WebDriver protocol. Therefore, the actual finding of elements within the DOM does not take place in the C# driver code. Instead, it's ultimately up to the browsers themselves to provide responses to these commands. For example, in Chromium/Chrome, the implementation of these commands seems to be stored as minified JavaScript within a C++ file (?!), and the generation of that code is based on JavaScript files from the Selenium codebase.

  • Nice, those Javascript files seem to be what I was looking for.
    – FDM
    Commented Apr 8, 2016 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.