FindElementByXPath("...") vs FindElement(By.XPath (".."))

96 views
Skip to first unread message

Wayne Gunn

unread,
Apr 27, 2022, 7:43:11 AM4/27/22
to Selenium Users
Is there any functional difference between these 2 usages? Are there conditions in which one is better than the other?

joseph...@gmail.com

unread,
Apr 27, 2022, 12:47:38 PM4/27/22
to Selenium Users
TL;DR - Use FindElement(By.XPath("..")) going forward.

I'm guessing you are using C# due to the capitalization of the method names.  If that is the case, here is the changelog for C#.  I will copy out the relevant note from the v4.0.0a4 section. The link to various changelogs can be found from https://www.selenium.dev/downloads/


* Added support for relative locators. To use relative locators in

.NET, take advantage of the new RelativeBy class to use with

FindElement and FindElements. This change also marks the IFindsBy*

interfaces (IFindsById, IFindsByName, etc.) as deprecated. The

presence of individual methods for finding elements by each mechanism

is an artifact of an older architecture, and with the standardization

of the locator methods in the W3C WebDriver Specification, they are
now just excess code, and will be deleted.

Wayne Gunn

unread,
Apr 27, 2022, 2:44:23 PM4/27/22
to Selenium Users
Actually I use vba
Reply all
Reply to author
Forward
0 new messages