-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛 Bug]: TypeScript types for driver.wait return single item instead of Array #14239
Comments
@slhck, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
This issue is looking for contributors. Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested. |
If I knew which change caused that regression I could have a deeper look, but the types and inner workings are bit too complex for me to grasp as an outsider. |
@slhck const primaryBtnsPromise = driver.wait<WebElement[]>(
until.elementsLocated(By.css("tp-yt-paper-button.style-primary"))
);
const rejectButtonPromise = driver.wait<WebElement[]>(
until.elementsLocated(By.css('button[aria-label*="Reject"]'))
); From what I understand, the issue shows up because typescript cannot differentiate between the following for
|
Yes, that might work. The thing is, this seems to be a regression. I have only encountered this error after upgrading from an older version of the types/selenium. |
@diemol, Can I pick this issue? Also if I understand correctly, I'd need to do changes in the types |
Hi @marlapativ, Yes, changing it there is correct. I've looked into the types, and it seems new types have been merged recently. However, using generics is still the best approach for now. as returning For WebElements, you should use Thanks, |
Is there any indication as to which changes introduced this regression? I am a bit lost in the number of files and commits. But yes, the return value of |
This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
Any updates on this? |
The bug exists in @types/selenium-webdriver version 4.1.23, published on 2024-05-31T17:06:57.036Z. The bug does not exist in 4.1.22, published on 2024-03-07T23:35:52.529Z. So @slhck, it makes sense that you observed a problem with compilation around the time you filed the bug. I tried looking at the diff between the two packages, but the problem is not immediately obvious at first glance. |
After git-bisecting DefinitelyTyped repo, I found the offending commit: DefinitelyTyped/DefinitelyTyped@b0f70c1 |
What happened?
I am using:
The TypeScript definition for
webdriver.wait
seems to be wrong or inconsistent.In the below code snippet, I get an error:
Yet,
result
is an array ofWebElement
s:Since
driver.wait
returns aWebElementPromise
, it assumes it's only a single item, whereas theuntil.elementsLocated
returns aCondition<WebElement[]>
.How can we reproduce the issue?
Relevant log output
Operating System
N/A
Selenium version
4.22.0
What are the browser(s) and version(s) where you see this issue?
N/A
What are the browser driver(s) and version(s) where you see this issue?
N/A
Are you using Selenium Grid?
No
The text was updated successfully, but these errors were encountered: