-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Cookie code for ruby #2230
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
Cookie code for ruby #2230
Conversation
👷 Deploy request for selenium-dev pending review.Visit the deploys page to approve it
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
@aguspe , thanks for helping with the PR. will wait for further information. |
halting work on this PR, as i didn't had the devtools gem installed. trying again. |
@@ -3,5 +3,81 @@ | |||
require 'spec_helper' | |||
|
|||
RSpec.describe 'Cookies' do | |||
let(:driver) { start_session } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use an instance variable in the specs.
Do not start and stop a driver outside of the spec_helper.rb
.
keep start_session to define which session you need (in this case the default works)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok @titusfortner , this isn't the file i added. I added this
require 'selenium-webdriver'
require 'rspec'
RSpec.describe 'CookiesTest' do
before(:each) do
@driver = Selenium::WebDriver.for :chrome
end
after(:each) do
@driver.quit
end
it 'adds a cookie' do
@driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html'
@driver.manage.add_cookie(name: 'key', value: 'value')
end
it 'gets a named cookie' do
@driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html'
@driver.manage.add_cookie(name: 'foo', value: 'bar')
cookie = @driver.manage.cookie_named('foo')
expect(cookie[:value]).to eq('bar')
end
it 'gets all cookies' do
@driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html'
@driver.manage.add_cookie(name: 'test1', value: 'cookie1')
@driver.manage.add_cookie(name: 'test2', value: 'cookie2')
cookies = @driver.manage.all_cookies
test1 = cookies.find { |c| c[:name] == 'test1' }
test2 = cookies.find { |c| c[:name] == 'test2' }
expect(test1[:value]).to eq('cookie1')
expect(test2[:value]).to eq('cookie2')
end
it 'deletes a cookie by name' do
@driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html'
@driver.manage.add_cookie(name: 'test1', value: 'cookie1')
@driver.manage.delete_cookie('test1')
expect(@driver.manage.cookie_named('test1')).to be_nil
end
it 'deletes a cookie using cookie object' do
@driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html'
cookie = { name: 'test2', value: 'cookie2' }
@driver.manage.add_cookie(cookie)
@driver.manage.delete_cookie('test2')
expect(@driver.manage.cookie_named('test2')).to be_nil
end
it 'deletes all cookies' do
@driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html'
@driver.manage.add_cookie(name: 'test1', value: 'cookie1')
@driver.manage.add_cookie(name: 'test2', value: 'cookie2')
@driver.manage.delete_all_cookies
expect(@driver.manage.all_cookies).to be_empty
end
it 'creates SameSite cookies' do
@driver.navigate.to 'http://www.example.com'
cookie_strict = {
name: 'key',
value: 'value',
same_site: 'Strict'
}
cookie_lax = {
name: 'key',
value: 'value',
same_site: 'Lax'
}
@driver.manage.add_cookie(cookie_strict)
@driver.manage.add_cookie(cookie_lax)
puts cookie_strict[:same_site]
puts cookie_lax[:same_site]
end
end
thanks for letting me know. I have halted work on this one. will come back to it later.
Closing this PR, will fix the code, environment as per information recvd after 2236 is resolved. |
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.
Description
Cookie code for ruby
Motivation and Context
Cookie code for ruby
Types of changes
Checklist
PR Type
Enhancement, Tests, Documentation
Description
Added comprehensive Ruby tests for cookies and frames interactions.
Updated documentation to reference new Ruby examples for cookies and frames.
Adjusted Hugo configuration to ignore specific errors.
Changes walkthrough 📝
2 files
Add Ruby tests for cookies management
Add Ruby tests for iframe interactions
8 files
Update English cookies documentation with Ruby examples
Update Japanese cookies documentation with Ruby examples
Update Portuguese cookies documentation with Ruby examples
Update Chinese cookies documentation with Ruby examples
Update English frames documentation with Ruby examples
Update Japanese frames documentation with Ruby examples
Update Portuguese frames documentation with Ruby examples
Update Chinese frames documentation with Ruby examples
1 files
Adjust Hugo configuration to ignore specific errors