Skip to content

更新 options.py#11623

Merged
symonk merged 4 commits intoSeleniumHQ:trunkfrom
71n9:trunk
Mar 11, 2023
Merged

更新 options.py#11623
symonk merged 4 commits intoSeleniumHQ:trunkfrom
71n9:trunk

Conversation

@71n9
Copy link
Copy Markdown
Contributor

@71n9 71n9 commented Feb 7, 2023

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

options = webdriver.ChromeOptions()
options.timeouts = {"pageLoad": 60}
# ValueError: Timeout keys can only be one of the following: implicit, pageLoad, script

I want to set the pageLoad timeout
When I execute the above code, I receive an error

Description

A small change

Motivation and Context

You can set successfully after modifying the logic

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 7, 2023

CLA assistant check
All committers have signed the CLA.

@diemol
Copy link
Copy Markdown
Member

diemol commented Feb 7, 2023

You set it in the driver after creating it: driver.set_page_load_timeout(30), for example.

@diemol diemol closed this Feb 7, 2023
@71n9
Copy link
Copy Markdown
Contributor Author

71n9 commented Feb 7, 2023

You set it in the driver after creating it: driver.set_page_load_timeout(30), for example.

# Part of the code of my program

options = webdriver.ChromeOptions()
options.add_experimental_option("debuggerAddress", f"127.0.0.1:{self.port}")
options.timeouts = {"pageLoad": 60000}
try:
   self.chromeDriver = webdriver.Chrome(service=Service(ChromedriverPath), options=options)
except Exception as err:
    print(err) # Message: timeout: Timed out receiving message from renderer: 300.000

image

I'm trying to solve this problem
I must set the timeout only before receiving this error, or I will have to wait 300 seconds to continue execution

@diemol
Copy link
Copy Markdown
Member

diemol commented Feb 7, 2023

That is different, you seem to be having issues creating the session. First try without this
options.add_experimental_option("debuggerAddress", f"127.0.0.1:{self.port}"), and then debug from that point.

If you have more questions, please use the following channels https://www.selenium.dev/support/

@71n9
Copy link
Copy Markdown
Contributor Author

71n9 commented Feb 7, 2023

Running for a long time will cause chrome to get stuck

那是不一样的,你好像在创建会话时遇到问题。首先尝试不使用this options.add_experimental_option("debuggerAddress", f"127.0.0.1:{self.port}"),然后从那一点开始调试。

如果您有更多问题,请使用以下渠道https://www.selenium.dev/support/

The session has been running for a long time Running for a long time will cause chrome to get stuck
All GUI functions of Chrome are invalid The manual shutdown procedure also fails
I have to force the end of chrome and restart the remote binding
Each re-link must wait 300 seconds

@titusfortner
Copy link
Copy Markdown
Member

@diemol we should encourage setting timeout values in options instead of after session starts.

@symonk can you check this logic? I can't tell what we support now vs what this code allows.

@titusfortner titusfortner reopened this Feb 7, 2023
@diemol
Copy link
Copy Markdown
Member

diemol commented Feb 7, 2023

I see. I was checking the docs and saw something else. Good to know.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 7, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.02 ⚠️

Comparison is base (6a47cc3) 55.14% compared to head (f66639e) 55.13%.

❗ Current head f66639e differs from pull request most recent head 48d883b. Consider uploading reports for the commit 48d883b to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #11623      +/-   ##
==========================================
- Coverage   55.14%   55.13%   -0.02%     
==========================================
  Files          85       85              
  Lines        5652     5652              
  Branches      228      227       -1     
==========================================
- Hits         3117     3116       -1     
- Misses       2307     2309       +2     
+ Partials      228      227       -1     
Impacted Files Coverage Δ
py/selenium/webdriver/common/options.py 75.51% <0.00%> (ø)
py/selenium/webdriver/common/service.py 95.04% <0.00%> (-0.83%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@titusfortner
Copy link
Copy Markdown
Member

It's one of the things added with w3c that probably needs to be updated in our docs in multiple places.

@71n9
Copy link
Copy Markdown
Contributor Author

71n9 commented Feb 8, 2023

The matter involved in the end should be very complex
Should lose a few hairs
thank you for all you do Thank you for open source software

@symonk
Copy link
Copy Markdown
Member

symonk commented Mar 11, 2023

Thanks, I think this is a slightly better implementation than what existed before (Enforcing every timeout was provided else giving an ambiguous error) to now making sure all keys are in the allowed sequence, this is ok for now. In future I think we should probably extract the 'known' keys and throwaway the rest without causing an error).

@symonk symonk merged commit 6ef8cb8 into SeleniumHQ:trunk Mar 11, 2023
alpatron pushed a commit to alpatron/selenium that referenced this pull request Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants