Skip to content
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]: ruby - Selenium::WebDriver::Error::InvalidArgumentError: invalid argument: 'handle' must be a string #14653

Open
chughes opened this issue Oct 25, 2024 · 4 comments
Labels
I-defect I-issue-template Applied to issues not following the template, or missing information.

Comments

@chughes
Copy link

chughes commented Oct 25, 2024

What happened?

We are experiencing intermittent and seemingly random test failures locally and in CI where chromedriver responds with "invalid argument: 'handle' must be a string" to a call from Selenium to get window handles. Detailed logs are included below.

How can we reproduce the issue?

ruby: 3.1.4p223
capybara: 3.40.0
selenium-webdriver: 4.25.0
chromedriver: 130.0.6723.69

tests failures can happen in any of our feature tests somewhat randomly where one run fails but will pass when re-run. The failures are reported around lines like:

expect(page).to have_content("xyz", wait: 20)

The error is reported as:
     1.1) Failure/Error: expect(page).to have_content("xyz", wait: 20)
          
          NoMethodError:
            undefined method `map' for 1:Integer
          
                      ids.map { |id| Bridge.element_class.new self, element_id_from(id) }
                         ^^^^
            Did you mean?  tap

     1.2) Failure/Error: raise ex, cause: cause
          
          Selenium::WebDriver::Error::InvalidArgumentError:
            invalid argument: 'handle' must be a string
              (Session info: chrome=130.0.6723.70)

I have included debug logs below and can try to recreate in a separate repo independent of our codebase if necessary.

Relevant log output

2024-10-25 15:21:52 DEBUG Selenium [:command] -> POST session/a7def88c1a04f1c586768fd0f05226d0/window 
2024-10-25 15:21:52 DEBUG Selenium [:command]    >>> http://127.0.0.1:9515/session/a7def88c1a04f1c586768fd0f05226d0/window | {"handle":{"element-6066-11e4-a52e-4f735466cecf":"f.7AB7119F5249502AE0F8482306FC499C.d.6A5B956DD7D43976E148E3D249883075.e.34"}} 
2024-10-25 15:21:52 DEBUG Selenium [:header]      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=UTF-8", "User-Agent"=>"selenium/4.25.0 (ruby macosx)", "Content-Length"=>"127"} 
[1729894912.583][INFO]: [a7def88c1a04f1c586768fd0f05226d0] COMMAND SwitchToWindow {
   "handle": {
      "element-6066-11e4-a52e-4f735466cecf": "f.7AB7119F5249502AE0F8482306FC499C.d.6A5B956DD7D43976E148E3D249883075.e.34"
   }
}
2024-10-25 15:21:52 DEBUG Selenium [:header]    <<<  {"content-length"=>["46"], "content-type"=>["application/json; charset=utf-8"], "cache-control"=>["no-cache"]} 
2024-10-25 15:21:52 DEBUG Selenium [:command] <- {"value":["7AB7119F5249502AE0F8482306FC499C"]} 
[1729894912.583][INFO]: [a7def88c1a04f1c586768fd0f05226d0] RESPONSE SwitchToWindow ERROR invalid argument: 'handle' must be a string
  (Session info: chrome=130.0.6723.70)
2024-10-25 15:21:52 DEBUG Selenium [:command] -> GET session/a7def88c1a04f1c586768fd0f05226d0/window/handles 
[1729894912.583][INFO]: [a7def88c1a04f1c586768fd0f05226d0] COMMAND GetWindows {
}
[1729894912.583][DEBUG]: DevTools WebSocket Command: Target.getTargets (id=36283) (session_id=) browser {
}
2024-10-25 15:21:52 DEBUG Selenium [:header]    <<<  {"content-length"=>["1561"], "content-type"=>["application/json; charset=utf-8"], "cache-control"=>["no-cache"]} 
2024-10-25 15:21:52 DEBUG Selenium [:command] <- {"value":{"error":"invalid argument","message":"invalid argument: 'handle' must be a string\n  (Session info: chrome=130.0.6723.70)","stacktrace":"0   chromedriver                        0x000000010345f634 cxxbridge1$str$ptr + 3645404\n1   chromedriver                        0x0000000103457e94 cxxbridge1$str$ptr + 3614780\n2   chromedriver                        0x0000000102ec4104 cxxbridge1$string$len + 88416\n3   chromedriver                        0x0000000102f33114 cxxbridge1$string$len + 543088\n4   chromedriver                        0x0000000102efaf54 cxxbridge1$string$len + 313264\n5   chromedriver                        0x0000000102efbba4 cxxbridge1$string$len + 316416\n6   chromedriver                        0x000000010342a1d4 cxxbridge1$str$ptr + 3427196\n7   chromedriver                        0x000000010342d518 cxxbridge1$str$ptr + 3440320\n8   chromedriver                        0x00000001034115f8 cxxbridge1$str$ptr + 3325856\n9   chromedriver                        0x000000010342dddc cxxbridge1$str$ptr + 3442564\n10  chromedriver                        0x000000010340287c cxxbridge1$str$ptr + 3265060\n11  chromedriver                        0x0000000103448884 cxxbridge1$str$ptr + 3551788\n12  chromedriver                        0x0000000103448a00 cxxbridge1$str$ptr + 3552168\n13  chromedriver                        0x0000000103457b2c cxxbridge1$str$ptr + 3613908\n14  libsystem_pthread.dylib             0x0000000188a21f94 _pthread_start + 136\n15  libsystem_pthread.dylib             0x0000000188a1cd34 thread_start + 8\n"}} 
[1729894912.583][DEBUG]: DevTools WebSocket Response: Target.getTargets (id=36283) (session_id=) browser {
   "targetInfos": [ {
      "attached": true,
      "browserContextId": "9FEEAF8971EE19927D1B59D8DC629E42",
      "canAccessOpener": false,
      "targetId": "7AB7119F5249502AE0F8482306FC499C",
      "title": "Motion iQ",
      "type": "page",
      "url": "http://127.0.0.1:65110/pathways/1"
   } ]
}
[1729894912.583][INFO]: [a7def88c1a04f1c586768fd0f05226d0] RESPONSE GetWindows [ "7AB7119F5249502AE0F8482306FC499C" ]

Operating System

macOS Sonoma 14.6.1

Selenium version

ruby: 3.1.4p223, selenium-webdriver: 4.25.0

What are the browser(s) and version(s) where you see this issue?

chrome 130.0.6723.70

What are the browser driver(s) and version(s) where you see this issue?

chromedriver 130.0.6723.69

Are you using Selenium Grid?

na

Copy link

@chughes, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol
Copy link
Member

diemol commented Nov 5, 2024

Does this happen with Firefox or earlier versions of Chrome?

@chughes
Copy link
Author

chughes commented Nov 7, 2024

Hi @diemol - yes, I get the same error when running in our CI which has chromedriver pegged to 116.0.5845.140

I have also installed and run with geckodriver 0.35.0 and am getting the same

@diemol diemol added I-issue-template Applied to issues not following the template, or missing information. and removed needs-triaging labels Nov 10, 2024
Copy link

Hi, @chughes.
Please follow the issue template, we need more information to reproduce the issue.

Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue.

Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough.

Reply to this issue when all information is provided, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-defect I-issue-template Applied to issues not following the template, or missing information.
Projects
None yet
Development

No branches or pull requests

2 participants