Closed carri747 closed 2 years ago
Can you provide a reproducible example?
Scenario: test Given test click
Given('test click', async function () {
await browser.url('https://onlineonly.christies.com/s/marc-chagall-colour-life-prints-artists-books-formerly-artists-estate/lots/3244');
let commonPage = new CommonPageObject();
let language = await commonPage.testLanguage();
await (await $('#onetrust-accept-btn-handler')).click();
await language.click();
// await browser.pause(5000);
await (await $('//a[@lang="en"]')).click();
});
export default class CommonPageObject {
async testLanguage(): Promise<ChainablePromiseElement<Promise<WebdriverIO.Element>>> {
return $('//a[@lang="zh"]');
}
}
You can see that WDIO click cookie popup to accept and after that change the language page to Chinese and after change the language again to English. Result:
I try the same with wdio 7.20.5 changing this Promise<ChainablePromiseElement<Promise
This works just fine however there are a few noteworthy things:
//a[@lang="zh"]
should be //a[@lang="zh-cn"]
Apologies, I accidentally ran the above with puppeteer instead of chromedriver. When using Chromedriver this is indeed an issue and I would say that this seems to be an issue in the Chromedriver and not with WebdriverIO, would you agree @christian-bromann ?
Reproduction path that works in puppeteer but not in chromedriver:
Given('I am on the home page', async () => {
await browser.setWindowSize(2000, 2000);
await browser.url('https://onlineonly.christies.com/s/marc-chagall-colour-life-prints-artists-books-formerly-artists-estate/lots/3244');
await $('#onetrust-accept-btn-handler').waitForDisplayed();
await $('#onetrust-accept-btn-handler').click();
await $('#onetrust-accept-btn-handler').waitForDisplayed({ reverse: true }); // make sure the dialog is gone before continuing to prevent flakyness
await $('//a[@lang="zh-cn"]').click();
await $('//a[@lang="zh-cn"]').waitForExist({ reverse: true }); // wait for language to be switched
await $('//a[@lang="zh"]').waitForExist(); // verify that the new languages have loaded
await $('//a[@lang="en"]').click();
await browser.pause(3000); // visually verify that the language changes from en to zh-cn back to en
});
@erwinheitzman thanks for investigating. It is unlikely that this is a problem with WebdriverIO but I don't want to be draw any conclusions without knowing more. Do you see any difference how the browser behaves between devtools and webdriver? My assumption is that the xPath (//a[contains(@href, "/sso?SaleID=28937&SaleNumber=19645")]
) is interpreted differently. Can we try with a different selector?
Sure, I can test this later today and will report the findings here
Using CSS selectors I got the same result: Error: Can't call elementClick on element with selector "a[lang="zh-cn"]" because element wasn't found
Is the element actually there?
Well yeah because it passes in puppeteer so the element is rendered.
I'm experiencing the same bug. And as soon as I added after the clicking, wait a few seconds it somehow worked
I've encountered the same problem described in the 5th and 6th points. The button is clicked and the navigation is successful, but the command(click in this case) times out. Setting the retry timeout a little higher and the pageLoadStrategy to 'none' helps a bit but is definitely not the required solution here. The call still times out when multiple features are executed simultaneously especially using saucelabs.
I found the same error in Edge. I don't know but maybe it's something regarding because both of them are base in Chromium
@christian-bromann and @erwinheitzman
The issue with this is that chromedriver throws error after clicking the element :
Request failed with status 500 due to unknown error: cannot determine loading status
and after that it retries to find the element again but by that time the language changes and element is no longer present
Just wait for all iframes:
await browser.setWindowSize(2000, 2000);
await browser.url('https://onlineonly.christies.com/s/marc-chagall-colour-life-prints-artists-books-formerly-artists-estate/lots/3244');
await $('#onetrust-accept-btn-handler').waitForDisplayed();
await $('#onetrust-accept-btn-handler').click();
await $('#onetrust-accept-btn-handler').waitForDisplayed({ reverse: true }); // make sure the dialog is gone before continuing to prevent flakyness
try {
await browser.waitUntil(
async () => await $$('//iframe').length === 5,
{
timeout: 5 * 1000, // 5 seconds
timeoutMsg: 'Message on failure'
}
);
} catch (e) {
console.log(e);
}
await $('//a[@lang="zh-cn"]').click();
@praveendvd that shouldn't be needed though, especially since that bug is resolved. It might be that it is reintroduced by accident.
EDIT: also the element isn't inside an iframe so I see no reason as to how this is connected
@erwinheitzman yes but waiting for iframe or adding an implicit wait fixes the issue , it doesnt seems to be wdio related
browser work in mysterious ways š it seems likely that a WebDriver error response unknown error: cannot determine loading status
is related to some iframes not being loaded.
Thanks for the investigation @praveendvd I agree with your resolution here that this is not really something that can be fixed within WebdriverIO.
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
7.16.13
Node.js Version
15.14.0
Mode
WDIO Testrunner
Which capabilities are you using?
What happened?
I updated chromedriver version from 102 to 103 due to chrome updated the version and the behavior that worked before the upgrade not it's not working properly now.
The situation:
What is your expected behavior?
No timeout trying to click in the link. The same code works with following version:
How to reproduce the bug.
In a cucumber step click in "a" element in html
This is more or less the code to reproduce
Relevant log output
Code of Conduct
Is there an existing issue for this?