CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Codeceptjs fails to find xpaths that use the second or greater instance of the element.

Open Jtech42 opened this issue 8 years ago • 5 comments

For example:

(.//*[contains(@cname, 'Girls')]/ins)[3]

Always fails, codeceptjs returns that xpath is an "invalid locator" which is weird because every other tool (like Chrome inspector) seems to find locators fine like that.

Jtech42 avatar Aug 09 '18 16:08 Jtech42

I agree. It should work so but it don't :(

sergejkaravajnij avatar Aug 31 '18 14:08 sergejkaravajnij

Is it true for {xpath: "(.//*[contains(@cname, 'Girls')]/ins)[3]" } locator too?

elukoyanov avatar Sep 11 '18 14:09 elukoyanov

Is it true for {xpath: "(.//*[contains(@cname, 'Girls')]/ins)[3]" } locator too?

Well, it would be fine if you test it yourself and write back here about results, isn't it? )

sergejkaravajnij avatar Sep 12 '18 14:09 sergejkaravajnij

Is it true for {xpath: "(.//*[contains(@cname, 'Girls')]/ins)[3]" } locator too?

I've seen it fail for this more complete syntax as well, in fact I think this would fail for me for a different reason entirely (if I didn't put the "xpath" in quotes when using codeceptjs).

Jtech42 avatar Sep 12 '18 14:09 Jtech42

@Jtech42 locators with indexes pose issues for most frameworks. Try being a bit more precise in selecting the secondary element ie:

{xpath: "(.//*[contains(@cname, 'Girls')]/ins[contains(text(), 'some InnerHTML text you care about
')])" }

GSasu avatar Oct 25 '18 14:10 GSasu