SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.63k stars 8.18k forks source link

[šŸ› Bug]: selenium.common.exceptions.JavascriptException: Message: javascript error: Object.hasOwn is not a function #12078

Closed qingfeng520 closed 1 year ago

qingfeng520 commented 1 year ago

What happened?

when run the code the code where report a bug: driver.find_elements(By.XPATH, '//*[@id="app-content"]/div/div[3]/div/div/button')

How can we reproduce the issue?

when run the code: driver.find_elements where report a bug

Relevant log output

File "D:\Softwares\Python3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 861, in find_elements
    return self.execute(Command.FIND_ELEMENTS, {"using": by, "value": value})["value"] or []
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Softwares\Python3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "D:\Softwares\Python3\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: javascript error: Object.hasOwn is not a function
  (Session info: chrome=113.0.5672.127)

Operating System

Windows11

Selenium version

Python 3.11.2

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

Chrome 113.0.5672.127

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

ChromeDriver 113.0.5672.63

Are you using Selenium Grid?

No response

github-actions[bot] commented 1 year ago

@qingfeng520, 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!

github-actions[bot] commented 1 year ago

Hi, @qingfeng520. 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.

diemol commented 1 year ago

We closed a similar issue last week because there was no way of reproducing it.

iniyavans commented 1 year ago

@diemol I'm also getting the same issue now

While running the below code

wait.until(EC.presence_of_element_located((By.XPATH, "//button[text()='Get Started']"))).click()

diemol commented 1 year ago

@iniyavans can you please provide a complete script to reproduce the issue? Otherwise it will stale and end up being closed.

iniyavans commented 1 year ago

@diemol will share my repo shortly!

iniyavans commented 1 year ago

EXTENSION_PATH = os.path.abspath('..') + '/metamask/extension_metamask.crx'

chromeDriver = os.path.abspath('..') + '/metamask/chromedriver/chromedriverV113'

chrome_options = Options()

chrome_options.add_extension(EXTENSION_PATH)

chrome_options.add_experimental_option("detach", True)

chrome_service = Service(chromeDriver)

driver = webdriver.Chrome(options=chrome_options, service=chrome_service)

driver.maximize_window()

driver.get("https://www.google.com/")

wait = WebDriverWait(driver, 20)

wait.until(EC.number_of_windows_to_be(2))

driver.switch_to.window(driver.window_handles[1])

wait.until(EC.presence_of_element_located((By.XPATH, "//button[text()='Get Started']"))).click()

@diemol I used above code

iniyavans commented 1 year ago

Screenshot 2023-05-24 at 3 20 46 PM Getting above issue @diemol

diemol commented 1 year ago

Two questions:

iniyavans commented 1 year ago

get the file from the below link @diemol

https://drive.google.com/file/d/1N_tBBT7S5QKdihD4oPy2MyMj-5Qv8tV9/view?usp=sharing @diemol

iniyavans commented 1 year ago

Answer for Q2: The basic selenium code will be working fine, I need to add the above extension file to automate my project. @diemol

diemol commented 1 year ago

OK, a bit of googling shows me that this is the browser extension https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn

And if it only happens with that extension, there is not much we can do. Have you reached out to them?

iniyavans commented 1 year ago

No @diemol We just add the extension during the browser launch, And also the same code worked fine before. The issue comes after updating the Chrome version to 113.

diemol commented 1 year ago

I understand, but Selenium is doing its job of launching the browser through ChromeDriver and loading the extension. The code in Selenium has not changed. So you either need to check with the extension maintainers or raise an issue to the ChromeDriver folks.

iniyavans commented 1 year ago

Okay @diemol, Thanks!

diemol commented 1 year ago

I will leave the links where you can report this, but still, I am not sure if this is something with the extension or the browser.

github-actions[bot] commented 1 year ago

Hi, @qingfeng520. This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team. Feel free to comment the issues that you raise back in this issue. Thank you.

disposablecarcass commented 10 months ago

Hi, @qingfeng520. This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team. Feel free to comment the issues that you raise back in this issue. Thank you.

Forgive my ignorance, but in that page you listed, how do I actually see if the issue was fixed in Chromedriver?

Does anyone know if this was resolved?

titusfortner commented 10 months ago

@disposablecarcass looks like a ticket was opened, but couldn't be reproduced with the provided example so it got closed: https://bugs.chromium.org/p/chromedriver/issues/detail?id=4446

If you have a reproducible example, please open a new ticket

disposablecarcass commented 10 months ago

@disposablecarcass looks like a ticket was opened, but couldn't be reproduced with the provided example so it got closed: https://bugs.chromium.org/p/chromedriver/issues/detail?id=4446

If you have a reproducible example, please open a new ticket

thanks. I read thru his instructions in the link you provided and that user describes the issue perfectly. do you know what issues they had reproducing this? did they just not want to install the extension? if so I could upload my whole python project with the crx already moved to the project root. would that help? please let me know if that would be sufficient for someone to reproduce the error. thanks

Edtit: I've created a new issue: https://bugs.chromium.org/p/chromedriver/issues/detail?id=4660

diemol commented 10 months ago

You'd need to ask that in the Chrome bug tracker.

NCLnclNCL commented 10 months ago

@disposablecarcass looks like a ticket was opened, but couldn't be reproduced with the provided example so it got closed: https://bugs.chromium.org/p/chromedriver/issues/detail?id=4446 If you have a reproducible example, please open a new ticket

thanks. I read thru his instructions in the link you provided and that user describes the issue perfectly. do you know what issues they had reproducing this? did they just not want to install the extension? if so I could upload my whole python project with the crx already moved to the project root. would that help? please let me know if that would be sufficient for someone to reproduce the error. thanks

Edtit: I've created a new issue: https://bugs.chromium.org/p/chromedriver/issues/detail?id=4660

Because lava moat of metamask , you need disable it https://community.metamask.io/t/can-i-disable-lavamoat/24845/2

github-actions[bot] commented 9 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.