Skip to content

Commit

Permalink
Fix removed Selenium::WebDriver::Remote::Capabilities.firefox method (
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavosobral committed Aug 30, 2023
1 parent 5b83967 commit 33ca869
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 33 deletions.
13 changes: 3 additions & 10 deletions lib/billy/browsers/capybara.rb
Expand Up @@ -48,24 +48,17 @@ def self.register_webkit_driver

def self.register_selenium_driver
::Capybara.register_driver :selenium_billy do |app|
capabilities = [
build_selenium_options_for_firefox,
Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true)
]
options = build_selenium_options_for_firefox

::Capybara::Selenium::Driver.new(app, capabilities: capabilities)
::Capybara::Selenium::Driver.new(app, options: options)
end

::Capybara.register_driver :selenium_headless_billy do |app|
options = build_selenium_options_for_firefox.tap do |opts|
opts.add_argument '-headless'
end
capabilities = [
options,
Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true)
]

::Capybara::Selenium::Driver.new(app, capabilities: capabilities)
::Capybara::Selenium::Driver.new(app, options: options)
end

::Capybara.register_driver :selenium_chrome_billy do |app|
Expand Down
79 changes: 56 additions & 23 deletions spec/lib/billy/browsers/capybara_spec.rb
@@ -1,28 +1,61 @@
require 'spec_helper'

describe 'Capybara drivers', type: :feature, js: true do
it 'allows HTTPS calls' do
proxy.stub('https://blog.howmanyleft.co.uk:443/api/read/json').and_return(
jsonp: {
posts: [
{
'regular-title' => 'News Item 1',
'url-with-slug' => 'http://example.com/news/1',
'regular-body' => 'News item 1 content here'
},
{
'regular-title' => 'News Item 2',
'url-with-slug' => 'http://example.com/news/2',
'regular-body' => 'News item 2 content here'
}
]
})

visit '/tumblr_api_https.html'

expect(page).to have_link('News Item 1', href: 'http://example.com/news/1')
expect(page).to have_content('News item 1 content here')
expect(page).to have_link('News Item 2', href: 'http://example.com/news/2')
expect(page).to have_content('News item 2 content here')
context "using selenium chrome headless billy driver" do
before { Capybara.current_driver = :selenium_chrome_headless_billy }

it 'allows HTTPS calls' do
proxy.stub('https://blog.howmanyleft.co.uk:443/api/read/json').and_return(
jsonp: {
posts: [
{
'regular-title' => 'News Item 1',
'url-with-slug' => 'http://example.com/news/1',
'regular-body' => 'News item 1 content here'
},
{
'regular-title' => 'News Item 2',
'url-with-slug' => 'http://example.com/news/2',
'regular-body' => 'News item 2 content here'
}
]
})

visit '/tumblr_api_https.html'

expect(page).to have_link('News Item 1', href: 'http://example.com/news/1')
expect(page).to have_content('News item 1 content here')
expect(page).to have_link('News Item 2', href: 'http://example.com/news/2')
expect(page).to have_content('News item 2 content here')
end
end

context "using selenium headless billy driver" do
before { Capybara.current_driver = :selenium_headless_billy }

it 'allows HTTPS calls' do
proxy.stub('https://blog.howmanyleft.co.uk:443/api/read/json').and_return(
jsonp: {
posts: [
{
'regular-title' => 'News Item 1',
'url-with-slug' => 'http://example.com/news/1',
'regular-body' => 'News item 1 content here'
},
{
'regular-title' => 'News Item 2',
'url-with-slug' => 'http://example.com/news/2',
'regular-body' => 'News item 2 content here'
}
]
})

visit '/tumblr_api_https.html'

expect(page).to have_link('News Item 1', href: 'http://example.com/news/1')
expect(page).to have_content('News item 1 content here')
expect(page).to have_link('News Item 2', href: 'http://example.com/news/2')
expect(page).to have_content('News item 2 content here')
end
end
end

0 comments on commit 33ca869

Please sign in to comment.