Skip to content

Add the http client configuration example for ruby #1704

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

Merged
merged 2 commits into from
May 3, 2024

Conversation

aguspe
Copy link
Contributor

@aguspe aguspe commented May 2, 2024

Description

This PR adds tests to exemplify the configuration of the HTTP client that is possible to use with Selenium webdriver from a ruby perspective

Screenshot 2024-05-02 at 19 51 49

Motivation and Context

It's important to keep examples of all the features for everyone using Selenium to be able to understand the full capabilities

Types of changes

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • Code example added (and I also added the example to all translated languages)
  • Improved translation
  • Added new translation (and I also added a notice to each document missing translation)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

Copy link

netlify bot commented May 2, 2024

👷 Deploy request for selenium-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit bf092aa

@aguspe aguspe marked this pull request as ready for review May 2, 2024 17:51
@qodo-merge-pro qodo-merge-pro bot added documentation Improvements or additions to documentation enhancement New feature or request labels May 2, 2024
Copy link
Contributor

qodo-merge-pro bot commented May 2, 2024

PR Description updated to latest commit (bf092aa)

Copy link
Contributor

qodo-merge-pro bot commented May 2, 2024

PR Review

⏱️ Estimated effort to review [1-5]

2, because the changes are straightforward and limited to adding examples and updating documentation. The code added is simple and well-contained within existing structures.

🧪 Relevant tests

Yes

🔍 Possible issues

No

🔒 Security concerns

No


✨ Review tool usage guide:

Overview:
The review tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.

The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.

  • When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
[pr_reviewer]
some_config1=...
some_config2=...

See the review usage page for a comprehensive guide on using this tool.

Copy link
Contributor

qodo-merge-pro bot commented May 2, 2024

PR Code Suggestions

CategorySuggestions                                                                                                                                                       
Enhancement
Refactor the HTTP client initialization into a before block for better test structure and reusability.

To ensure that the HTTP client is properly configured and reusable, it's recommended to
define the client in a before block and use instance variables for reuse in multiple
tests. This approach enhances test readability and efficiency.

examples/ruby/spec/drivers/http_client_spec.rb [6-9]

-it 'sets client configuration' do
-  client = Selenium::WebDriver::Remote::Http::Default.new(open_timeout: 30, read_timeout: 30)
-  expect(client.open_timeout).to eq 30
+before(:each) do
+  @client = Selenium::WebDriver::Remote::Http::Default.new(open_timeout: 30, read_timeout: 30)
 end
 
+it 'sets client configuration' do
+  expect(@client.open_timeout).to eq 30
+end
+
Best practice
Use an after block to ensure the driver quits after each test, enhancing resource management.

To ensure that all resources are properly released and to avoid potential browser hangs or
memory leaks, it's recommended to use an after block to quit the driver.

examples/ruby/spec/drivers/http_client_spec.rb [11-15]

+after(:each) do
+  @driver.quit if @driver
+end
+
 it 'uses the custom http client' do
   client = Selenium::WebDriver::Remote::Http::Default.new
-  driver = Selenium::WebDriver.for :chrome, http_client: client
-  driver.get(url)
-  driver.quit
+  @driver = Selenium::WebDriver.for :chrome, http_client: client
+  @driver.get(url)
 end
 

✨ Improve tool usage guide:

Overview:
The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.

  • When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
[pr_code_suggestions]
some_config1=...
some_config2=...

See the improve usage page for a comprehensive guide on using this tool.

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @aguspe!

@diemol diemol merged commit a852596 into SeleniumHQ:trunk May 3, 2024
selenium-ci added a commit that referenced this pull request May 3, 2024
Add the http client configuration example

Co-authored-by: aguspe <agustin.pe94@gmail.com>

[deploy site] a852596
@aguspe
Copy link
Contributor Author

aguspe commented May 3, 2024

Thank

Thank you for the quick merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request Review effort [1-5]: 2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants