You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks for contributing to the Selenium site and documentation! A PR well described will help maintainers to review and merge it quickly
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.
added cookie ruby file
Description
added cookie ruby file
Motivation and Context
added cookie ruby file
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)
Latest suggestions up to 946188b
Explore these optional code suggestions:
Category
Suggestion
Impact
General
Add error case testing
Add error handling for the case when the named cookie doesn't exist. The current test only verifies the happy path, but should also test the error case to ensure proper exception handling.
it 'gets a named cookie' do
driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html'
# Add cookie into current browser context
driver.manage.add_cookie(name: 'foo', value: 'bar')
# Get cookie details with named cookie 'foo'
cookie = driver.manage.cookie_named('foo')
expect(cookie[:value]).to eq('bar')
++ # Verify error is raised for non-existent cookie+ expect { driver.manage.cookie_named('non_existent') }.to raise_error(Selenium::WebDriver::Error::NoSuchCookieError)
end
Apply / Chat
Suggestion importance[1-10]: 7
__
Why: The suggestion improves test coverage by adding a negative test case for retrieving a non-existent cookie. This enhances the robustness of the new tests, aligning with the PR's goal of adding comprehensive cookie operation tests.
Add a check to verify that both cookies are found. If either test1_cookie or test2_cookie is nil, the test will fail with a nil reference error when accessing [:value] rather than a clear assertion failure.
it 'gets all cookies' do
driver.navigate.to "https://www.selenium.dev/selenium/web/blank.html"
# Add cookies into current browser context
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")
# Get cookies
cookies = driver.manage.all_cookies
# Verify both cookies exist with correct values
test1_cookie = cookies.find { |c| c[:name] == "test1" }
test2_cookie = cookies.find { |c| c[:name] == "test2" }
+ expect(test1_cookie).not_to be_nil+ expect(test2_cookie).not_to be_nil
expect(test1_cookie[:value]).to eq("cookie1")
expect(test2_cookie[:value]).to eq("cookie2")
end
Suggestion importance[1-10]: 6
__
Why: The suggestion improves test clarity. Adding checks for nil before accessing [:value] on test1_cookie and test2_cookie provides a more specific assertion failure if a cookie is not found, rather than a less informative nil reference error.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.
added cookie ruby file
Description
added cookie ruby file
Motivation and Context
added cookie ruby file
Types of changes
Checklist
PR Type
Tests
Description
Add comprehensive RSpec tests for cookie management in Ruby
Test adding, retrieving, and deleting cookies via WebDriver
Ensure correct behavior for single and multiple cookies
Validate error handling for deleted cookies
Changes walkthrough 📝
cookies_spec.rb
Add and validate cookie management tests in Ruby
examples/ruby/spec/interactions/cookies_spec.rb