- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.5k
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
          
     Closed
      
      
    
  
     Closed
                    Cookie code for ruby #2230
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            3 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      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
    
  
  
    
              
              
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -2,6 +2,44 @@ | |
|  | ||
| require 'spec_helper' | ||
|  | ||
| RSpec.describe 'Frames' do | ||
| let(:driver) { start_session } | ||
| RSpec.describe 'Frames Test' do | ||
| it 'interacts with elements inside iframes' do | ||
| driver = Selenium::WebDriver.for :chrome | ||
| driver.manage.timeouts.implicit_wait = 0.5 | ||
|  | ||
| # Navigate to URL | ||
| driver.get('https://www.selenium.dev/selenium/web/iframes.html') | ||
|  | ||
| # Switch to iframe using WebElement | ||
| iframe = driver.find_element(id: 'iframe1') | ||
| driver.switch_to.frame(iframe) | ||
| expect(driver.page_source.include?('We Leave From Here')).to be true | ||
|  | ||
| # Interact with email field | ||
| email_element = driver.find_element(id: 'email') | ||
| email_element.send_keys('[email protected]') | ||
| email_element.clear | ||
| driver.switch_to.default_content | ||
|  | ||
| # Switch to iframe using name | ||
| driver.find_element(name: 'iframe1-name') | ||
| driver.switch_to.frame(iframe) | ||
| expect(driver.page_source.include?('We Leave From Here')).to be true | ||
|  | ||
| email = driver.find_element(id: 'email') | ||
| email.send_keys('[email protected]') | ||
| email.clear | ||
| driver.switch_to.default_content | ||
|  | ||
| # Switch to iframe using index | ||
| driver.switch_to.frame(0) | ||
| expect(driver.page_source.include?('We Leave From Here')).to be true | ||
|  | ||
| # Leave frame | ||
| driver.switch_to.default_content | ||
| expect(driver.page_source.include?('This page has iframes')).to be true | ||
|  | ||
| # Quit the browser | ||
| driver.quit | ||
| end | ||
| end | ||
  
    
      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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  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.
  
    
  
    
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')
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'
end
end
thanks for letting me know. I have halted work on this one. will come back to it later.