bbaia / protractor-net

The .NET port of Protractor, an E2E test framework for Angular apps
MIT License
115 stars 72 forks source link

find by binding returns matches where binding name is substring of another #63

Closed SubjectiveReality closed 7 years ago

SubjectiveReality commented 7 years ago

Ran into this today. I have two bindings on a page I am testing:

When I do the following, both of the above elements are found instead of the expected one:

var Blahs = row.FindElements(NgBy.Binding("p[0].Blah"));

bbaia commented 7 years ago

Added an 'exactMatch' option to NgByBinding & NgByRepeater locators : var Blahs = row.FindElements(NgBy.Binding("p[0].Blah", true));

Try new v0.10.1 and let me know

SubjectiveReality commented 7 years ago

Unfortunately, it appears to have a conflict with the PageFactory...

System.ArgumentException was unhandled by user code
  HResult=-2147024809
  Message=Custom finder type must expose a public constructor with a string argument
  Source=WebDriver.Support
  StackTrace:
       at OpenQA.Selenium.Support.PageObjects.ByFactory.From(FindsByAttribute attribute)
       at OpenQA.Selenium.Support.PageObjects.DefaultPageObjectMemberDecorator.CreateLocatorList(MemberInfo member)
       at OpenQA.Selenium.Support.PageObjects.DefaultPageObjectMemberDecorator.Decorate(MemberInfo member, IElementLocator locator)
       at OpenQA.Selenium.Support.PageObjects.PageFactory.InitElements(Object page, IElementLocator locator, IPageObjectMemberDecorator decorator)
       at OpenQA.Selenium.Support.PageObjects.PageFactory.InitElements(ISearchContext driver, Object page)

^ in conjunction with something like

[FindsBy(How = How.Custom, CustomFinderType = typeof(NgByBinding), Using = "p[0].BlahDescription")]
private IList<IWebElement> lstBlahDescriptions { get; set; }
bbaia commented 7 years ago

Looks like I've introduced a regression. I'll fix or this week-end.

bbaia commented 7 years ago

Added 'NgByExactBinding' & 'NgByExactRepeater' to support Page Objects pattern (coherent with original Protractor project).

var Blahs = row.FindElements(NgBy.ExactBinding("p[0].Blah"));

[FindsBy(How = How.Custom, CustomFinderType = typeof(NgByExactBinding), Using = "p[0].Blah")]

Try new v0.10.2 and let me know

SubjectiveReality commented 7 years ago

Working great! Thank you!