Skip to content

Commit

Permalink
[rb] refactor to not get deprecation warnings in specs
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jul 11, 2020
1 parent 0c06289 commit b30f9a6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions rb/spec/integration/selenium/webdriver/chrome/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Chrome
it 'passes emulated device correctly' do
options.add_emulation(device_name: 'Nexus 5')

create_driver!(options: options) do |driver|
create_driver!(capabilities: options) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to include('Nexus 5')
end
Expand All @@ -37,7 +37,7 @@ module Chrome
it 'passes emulated user agent correctly' do
options.add_emulation(user_agent: 'foo;bar')

create_driver!(options: options) do |driver|
create_driver!(capabilities: options) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to eq('foo;bar')
end
Expand All @@ -46,7 +46,7 @@ module Chrome
it 'passes args correctly' do
options.add_argument('--user-agent=foo;bar')

create_driver!(options: options) do |driver|
create_driver!(capabilities: options) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to eq('foo;bar')
end
Expand All @@ -55,7 +55,7 @@ module Chrome
it 'should be able to run in headless mode with #headless!' do
options.headless!

create_driver!(options: options) do |driver|
create_driver!(capabilities: options) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to match(/HeadlessChrome/)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module EdgeChrome
it 'passes emulated device correctly' do
options.add_emulation(device_name: 'Nexus 5')

create_driver!(options: options) do |driver|
create_driver!(capabilities: options) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to include('Nexus 5')
end
Expand All @@ -37,7 +37,7 @@ module EdgeChrome
it 'passes emulated user agent correctly' do
options.add_emulation(user_agent: 'foo;bar')

create_driver!(options: options) do |driver|
create_driver!(capabilities: options) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to eq('foo;bar')
end
Expand All @@ -46,7 +46,7 @@ module EdgeChrome
it 'passes args correctly' do
options.add_argument('--user-agent=foo;bar')

create_driver!(options: options) do |driver|
create_driver!(capabilities: options) do |driver|
ua = driver.execute_script 'return window.navigator.userAgent'
expect(ua).to eq('foo;bar')
end
Expand All @@ -55,7 +55,7 @@ module EdgeChrome
# it 'should be able to run in headless mode with #headless!' do
# options.headless!
#
# create_driver!(options: options) do |driver|
# create_driver!(capabilities: options) do |driver|
# ua = driver.execute_script 'return window.navigator.userAgent'
# expect(ua).to match(/HeadlessChrome/)
# end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ def read_generated_prefs(from = nil)
end

it 'should instantiate the browser with the correct profile' do
create_driver!(options: Options.new(profile: profile)) do |driver|
create_driver!(capabilities: Options.new(profile: profile)) do |driver|
expect { wait(5).until { driver.find_element(id: 'oneline') } }.not_to raise_error
end
end

it 'should be able to use the same profile more than once' do
create_driver!(options: Options.new(profile: profile)) do |driver1|
create_driver!(capabilities: Options.new(profile: profile)) do |driver1|
expect { wait(5).until { driver1.find_element(id: 'oneline') } }.not_to raise_error
create_driver!(options: Options.new(profile: profile)) do |driver2|
create_driver!(capabilities: Options.new(profile: profile)) do |driver2|
expect { wait(5).until { driver2.find_element(id: 'oneline') } }.not_to raise_error
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def call(env)
req = Rack::Request.new(env)
body = case req['upload']
when Array
req['upload'].map { |upload| upload[:tempfile].read }.join("\n")
req.params['upload'].map { |upload| upload[:tempfile].read }.join("\n")
when Hash
req['upload'][:tempfile].read
req.params['upload'][:tempfile].read
end

[200, {'Content-Type' => 'text/html'}, [body]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ def check_for_previous_error
end

def create_remote_driver(opt = {})
opt[:desired_capabilities] = remote_capabilities
options = opt.delete(:capabilities)
opt[:capabilities] = [remote_capabilities]
opt[:capabilities] << options if options
opt[:url] = ENV['WD_REMOTE_URL'] || remote_server.webdriver_url
opt[:http_client] ||= WebDriver::Remote::Http::Default.new

Expand Down

0 comments on commit b30f9a6

Please sign in to comment.