var closestByClass = myLocator.Closest("foo");
var closestByAttribute = myLocator.Closest("title", "Click this to do foo");
var closestByElementAndAttribute = myLocator.Closest("div", "data-account-balance", "42");
There are some edge cases, but it works for my use case.
I'm using the .NET bindings, but you can convert the following to your environment.
I defined extension methods (input validation excluded for brevity):
Which are used like so:
There are some edge cases, but it works for my use case.