niloc132 / gxt-driver

Other
5 stars 7 forks source link

Enhance the fuzzy finder methods with exactly matching finder methods #14

Open PeterWippermann opened 8 years ago

PeterWippermann commented 8 years ago

In general model finder classes use "fuzzy search", i.e. findElement(By.xpath(".//*[contains(text(),"+escaped+")]")).

Examples are:

In addition to this I find it essential to have exact matchers also. Image a scenario where I have two buttons "new release" and "delete new release". So if I'm trying to find with label text "new release" now, it may happen that I only find the delete button. I don't even have the chance to find the other button then because, you know, I can only search for one item at a time.

I propose to add further methods to the finders, e.g.

The implementation of these should use findElement(By.xpath(".//*[text()="+escaped+"]"))

niloc132 commented 8 years ago

The trick here becomes whitespace, and any content (glyph icons? ::before/::after content?) added by the appearance - I believe the text() will hit those as well, and surprise your test cases. It has been a few years, but I think that is why I implemented all of these with contains() in the first place.

Use of normalize-space(text()) will at least solve leading/trailing space, but given that newlines/tabs/multiple-spaces in html are rendered as a single space, the tester may be surprised to find that " " is the same as " ".

Worth a shot for sure, with lots of warnings in Javadoc and the like that it must be an EXACT match. (and as with your other issue, this means "patches welcome", feel free to submit something doc'd and tested).

So if I'm trying to find with label text "new release" now, it may happen that I only find the delete button. I don't even have the chance to find the other button then because, you know, I can only search for one item at a time.

Inside the finder that is true, but you always have the ability to perform a search outside a finder, and then create the widget directly based on the element you found.

PeterWippermann commented 8 years ago

Good point @niloc132 - I sent you an email about contributing some days ago. Would be great if you could briefly answer it, because I'm afraid I'd need to clarify some more details with you.