Closed alek75 closed 1 year ago
Duplicate of #10040
@christian-bromann Since you closed the ticket "as completed" I've expected the issue to be fixed in the newer version... but i guess that's not the case > the issue still persist in "8.6.9"
Based on your description my assumption was that the issue described in #10040 is the same as described in here. If that is not the case please provide a reproducible example, thank you!
@christian-bromann I've checked #10040. Indeed "h1=someTxt" is fixed, but did you check searching by partial txt? > "h1*=someTxt" < I still have issues with it
Also, we are using these locators not only as this >>> $(h1=someTxt) but also like the following example: var obj1 = $("div") var obj2 = obj1.$("h1=someTxt")
In this case it seems that neither "h1=someTxt" or "h1*=someTxt" are working properly
Thanks
In this case it seems that neither "h1=someTxt" or "h1*=someTxt" are working properly
Do you have a reproducible example?
Will see what i can do...
Cheers
@christian-bromann While 8.6.9 (through #10046) does indeed solve some of the selector issues that were introduced, we still have failing tests that search for e.g. $("td*=Latitude")
so that needs to be addressed.
Reproducible example: add this test to webdriverio:
diff --git a/e2e/browser-runner/lit.test.js b/e2e/browser-runner/lit.test.js
index 792007069..db8c74cff 100644
--- a/e2e/browser-runner/lit.test.js
+++ b/e2e/browser-runner/lit.test.js
@@ -138,6 +138,14 @@ describe('Lit Component testing', () => {
expect(await $('div*=me').getHTML(false)).toBe('Find me')
})
+ it('fetches inner element by content correctly', async () => {
+ render(
+ html`<div><div><span>Find me</span></div></div>`,
+ document.body
+ )
+ expect(await $('div*=me').getText()).toBe('Find me')
+ })
+
it('fetches the parent element by content correctly', async () => {
render(
html`<button><span>Click Me!</span></button>`,
go to the e2e
directory, run npm run test:browser:lit
and watch the test fail.
[Edit: Just for fun, I ran this test against v8.6.0 and there it passes.]
@gjvoosten thanks for providing this great example. I was able to reproduce it. I was able to find $('div=Find me')
but not $('div*=me')
while it was possible to find $('span*=me')
. We could change the selector to:
- .//div[contains(text(), "me")]
+ .//div[contains(text(), "me") or contains(., "me")]
Which could come with other issues, e.g. if you have a lot of nested divs, it will take the most outer div element which can end up not being the element you are looking for. I rather have a more stricter working selector than a loose one.
Hi @christian-bromann! Seeing as this is still part of a patch release (not minor or even major), and the behaviour has changed, many people might be surprised why their tests suddenly started failing with this new webdriverio version. So the safest bet would be to make it behave the same as before. Now if the former behaviour was ill-defined or under-documented, it's okay to change it, but be sure to mark this clearly in the release notes / changelog, as we don't want to make people search for relevant issues to find out what happened (and/or how to fix it).
@gjvoosten make sense, I will add a note to the release notes
@christian-bromann In any case, aside from documenting which exact element gets matched, the main problem is of course that currently the test I described above doesn't find the element at all, so that still needs to be fixed. (And maybe this issue should be reopened until it is?)
Edit: And as per #9992 the preference is for finding the innermost matching element, that test is probably better written as:
diff --git a/e2e/browser-runner/lit.test.js b/e2e/browser-runner/lit.test.js
index 792007069..19161a072 100644
--- a/e2e/browser-runner/lit.test.js
+++ b/e2e/browser-runner/lit.test.js
@@ -138,6 +138,14 @@ describe('Lit Component testing', () => {
expect(await $('div*=me').getHTML(false)).toBe('Find me')
})
+ it('fetches inner element by content correctly', async () => {
+ render(
+ html`<div><div><span>Find me</span></div></div>`,
+ document.body
+ )
+ expect(await $('div*=me').getHTML(false)).toBe('<span>Find me</span>')
+ })
+
it('fetches the parent element by content correctly', async () => {
render(
html`<button><span>Click Me!</span></button>`,
to make this fact clear.
Raised another PR with fixes for this.
wdio - 8.7.0
HTML example:
<div>
<span>Test me</span>
</div>
wdio example:
let sample = await $('div=Test') console.log('>>>> ', await sample.getHTML()) Error: Can't call getHTML on element with selector "div=Test" because element wasn't found
@christian-bromann Is this example reproducible? Thanks...
The PR mentioned above is not released yet.
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
8.6.8
Node.js Version
16.14.0
Mode
Standalone Mode
Which capabilities are you using?
No response
What happened?
Example "div=SomeTxt" or "div*=someTxt" are not working after wdio/local-runner version 8.6.2 (last working version). This is applicable to all tags >>> h1, a, span etc.
The other packages I am using are: "@wdio/cli": "8.6.8", "@wdio/cucumber-framework": "8.6.8", "@wdio/spec-reporter": "8.6.8", "@wdio/local-runner": "8.6.2", "wdio-chromedriver-service": "8.1.1", "wdio-intercept-service": "4.4.0",
As you can see the only downgraded package is "@wdio/local-runner". If I can help you with some other info, please let me know...
UPDATE: In the version 8.6.9 it looks like the case $(h1=someTxt) is fixed but I still have issues using $(h1=someTxt) Also in the following example it looks like none of the locators ("h1=someTxt" or "h1=someTxt") are working properly... var obj1 = $("div") var obj2 = obj1.$("h1*=someTxt")
What is your expected behavior?
No response
How to reproduce the bug.
Just use the locator div=someTxt You can use it with any tags, not only with div...
wdio/local-runner version 8.6.2 (last working version)
Relevant log output
Code of Conduct
Is there an existing issue for this?