Skip to content

Commit

Permalink
[rb] change default edge to chrome and get tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jul 13, 2020
1 parent a392a72 commit 444af06
Show file tree
Hide file tree
Showing 24 changed files with 790 additions and 81 deletions.
3 changes: 1 addition & 2 deletions Rakefile
Expand Up @@ -256,15 +256,14 @@ task test_rb_local: [
('//rb:safari-preview-test' if SeleniumRake::Checks.mac?),
('//rb:safari-test' if SeleniumRake::Checks.mac?),
('//rb:ie-test' if SeleniumRake::Checks.windows?),
('//rb:edge-test' if SeleniumRake::Checks.windows?)
('//rb:edge-test' unless SeleniumRake::Checks.linux?)
].compact

task test_rb_remote: [
'//rb:remote-chrome-test',
'//rb:remote-firefox-test',
('//rb:remote-safari-test' if SeleniumRake::Checks.mac?),
('//rb:remote-ie-test' if SeleniumRake::Checks.windows?),
('//rb:remote-edge-test' if SeleniumRake::Checks.windows?)
].compact

task test_py: [:py_prep_for_install_release, 'py:marionette_test']
Expand Down
4 changes: 4 additions & 0 deletions rake_tasks/selenium_rake/checks.rb
Expand Up @@ -15,6 +15,10 @@ def mac?
(RbConfig::CONFIG['host_os'] =~ /darwin|mac os/) != nil
end

def linux?
!windows? && !mac?
end

def dir_separator
File::ALT_SEPARATOR || File::SEPARATOR
end
Expand Down
39 changes: 14 additions & 25 deletions rb/build.desc
Expand Up @@ -4,8 +4,8 @@ rubygem(
"//rb:chrome",
"//rb:common",
"//rb:devtools",
"//rb:edge",
"//rb:edge-chrome",
"//rb:edge-html",
"//rb:firefox",
"//rb:ie",
"//rb:safari",
Expand Down Expand Up @@ -87,51 +87,39 @@ ruby_test(name = "remote-chrome",
deps = [":chrome"]
)

ruby_library(name = "edge",
ruby_library(name = "edge-html",
srcs = [
"lib/selenium/webdriver/edge_html/**/*.rb",
"lib/selenium/webdriver/edge.rb"
],
deps = [":common"]
)

ruby_test(name = "edge",
ruby_library(name = "edge-chrome",
srcs = [
"spec/integration/selenium/webdriver/*_spec.rb",
"spec/integration/selenium/webdriver/edge_html/**/*_spec.rb"
],
include = [
"rb/spec/integration",
"build/rb/lib"
"lib/selenium/webdriver/edge_chrome/**/*.rb",
"lib/selenium/webdriver/edge.rb"
],
deps = [":edge"]
deps = [":chrome"]
)

ruby_test(name = "remote-edge",
ruby_test(name = "edge",
srcs = [
"spec/integration/selenium/webdriver/*_spec.rb",
"spec/integration/selenium/webdriver/edge_html/**/*_spec.rb",
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
"spec/integration/selenium/webdriver/edge/**/*_spec.rb"
],
include = [
"rb/spec/integration",
"build/rb/lib"
],
deps = [":edge"]
)

ruby_library(name = "edge-chrome",
srcs = [
"lib/selenium/webdriver/edge_chrome/**/*.rb",
"lib/selenium/webdriver/edge.rb"
],
deps = [":chrome"]
deps = [":edge-chrome"]
)

ruby_test(name = "edge-chrome",
ruby_test(name = "remote-edge",
srcs = [
"spec/integration/selenium/webdriver/*_spec.rb",
"spec/integration/selenium/webdriver/edge_chrome/**/*_spec.rb"
"spec/integration/selenium/webdriver/edge/**/*_spec.rb",
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
],
include = [
"rb/spec/integration",
Expand Down Expand Up @@ -286,7 +274,8 @@ ruby_test(name = "unit",
],
deps = [
":chrome",
":edge",
":edge-html",
":edge-chrome",
":firefox",
":ie",
":safari",
Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/edge.rb
Expand Up @@ -56,8 +56,8 @@ def self.path=(path)
def self.path
@path ||= nil
end
end # EdgeChrome
end # EdgeHtml

Edge = EdgeHtml # Alias EdgeHtml as Edge for now
Edge = EdgeChrome
end # WebDriver
end # Selenium
3 changes: 2 additions & 1 deletion rb/lib/selenium/webdriver/edge_chrome/options.rb
Expand Up @@ -23,7 +23,8 @@ module Selenium
module WebDriver
module EdgeChrome
class Options < Selenium::WebDriver::Chrome::Options
BROWSER = 'MSEdge'
KEY = 'ms:edgeOptions'
BROWSER = 'MicrosoftEdge'

private

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/edge_html/driver.rb
Expand Up @@ -31,7 +31,7 @@ class Driver < WebDriver::Driver
include DriverExtensions::TakesScreenshot

def browser
:edge
:edge_html
end
end # Driver
end # EdgeHtml
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/remote/capabilities.rb
Expand Up @@ -82,7 +82,7 @@ def chrome(opts = {})
end

def edge(opts = {})
edge_html(opts)
edge_chrome(opts)
end

def edge_html(opts = {})
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/integration/selenium/webdriver/action_builder_spec.rb
Expand Up @@ -38,7 +38,7 @@ module WebDriver
expect(driver.find_element(id: 'result').text.strip).to be_empty
end

it 'can send keys with shift pressed', except: {browser: %i[edge safari safari_preview]} do
it 'can send keys with shift pressed', except: {browser: %i[safari safari_preview]} do
driver.navigate.to url_for('javascriptPage.html')

event_input = driver.find_element(id: 'theworks')
Expand All @@ -53,7 +53,7 @@ module WebDriver
expect(keylogger.text.strip).to match(/^(focus )?keydown keydown keypress keyup keydown keypress keyup keyup$/)
end

it 'can press and release modifier keys', except: {browser: %i[edge safari]} do
it 'can press and release modifier keys', except: {browser: :safari} do
driver.navigate.to url_for('javascriptPage.html')

event_input = driver.find_element(id: 'theworks')
Expand Down Expand Up @@ -161,7 +161,7 @@ module WebDriver

it 'can release pressed buttons via release action', except: [{browser: :safari},
{driver: :remote, browser: :ie}],
only: {browser: %i[edge chrome edge_chrome firefox ie]} do
only: {browser: %i[edge chrome firefox ie]} do
driver.navigate.to url_for('javascriptPage.html')

event_input = driver.find_element(id: 'clickField')
Expand Down
7 changes: 3 additions & 4 deletions rb/spec/integration/selenium/webdriver/driver_spec.rb
Expand Up @@ -22,7 +22,7 @@
module Selenium
module WebDriver
describe Driver do
it_behaves_like 'driver that can be started concurrently', except: {browser: %i[edge safari safari_preview]}
it_behaves_like 'driver that can be started concurrently', except: {browser: %i[safari safari_preview]}

it 'should get the page title' do
driver.navigate.to url_for('xhtmlTest.html')
Expand Down Expand Up @@ -292,7 +292,7 @@ def save_screenshot_and_assert(path)
expect(driver.execute_script('return true;')).to eq(true)
end

it 'should raise if the script is bad', except: {browser: %i[edge]} do
it 'should raise if the script is bad' do
driver.navigate.to url_for('xhtmlTest.html')
expect { driver.execute_script('return squiggle();') }.to raise_error(Selenium::WebDriver::Error::JavascriptError)
end
Expand Down Expand Up @@ -363,9 +363,8 @@ def save_screenshot_and_assert(path)
expect(result).to eq(3)
end

# Edge BUG - https://connect.microsoft.com/IE/feedback/details/1849991/
# Safari raises TimeoutError instead
it 'times out if the callback is not invoked', except: {browser: %i[edge safari safari_preview]} do
it 'times out if the callback is not invoked', except: {browser: %i[safari safari_preview]} do
expect {
# Script is expected to be async and explicitly callback, so this should timeout.
driver.execute_async_script 'return 1 + 2;'
Expand Down
Expand Up @@ -21,8 +21,8 @@

module Selenium
module WebDriver
module EdgeChrome
describe Driver, only: {driver: :edge_chrome} do
module Edge
describe Driver, only: {driver: :edge} do
it 'gets and sets network conditions' do
driver.network_conditions = {offline: false, latency: 56, throughput: 789}
expect(driver.network_conditions).to eq(
Expand Down Expand Up @@ -53,6 +53,6 @@ module EdgeChrome
end
end
end
end # EdgeChrome
end # Edge
end # WebDriver
end # Selenium
Expand Up @@ -22,7 +22,7 @@
module Selenium
module WebDriver
module EdgeChrome
describe Options, only: {browser: :edge_chrome} do
describe Options, only: {browser: :edge} do
subject(:options) { Options.new }

it 'passes emulated device correctly' do
Expand Down
Expand Up @@ -21,7 +21,7 @@

module Selenium
module WebDriver
module EdgeChrome
module Edge
describe Profile do
let(:profile) { Profile.new }

Expand Down Expand Up @@ -54,6 +54,6 @@ module EdgeChrome
}.to raise_error(Selenium::WebDriver::Error::WebDriverError)
end
end
end # Chrome
end # Edge
end # WebDriver
end # Selenium
15 changes: 7 additions & 8 deletions rb/spec/integration/selenium/webdriver/manager_spec.rb
Expand Up @@ -22,8 +22,8 @@
module Selenium
module WebDriver
describe Manager do
describe 'logs', except: [{browser: %i[edge edge_chrome firefox ie safari safari_preview]},
{driver: :remote, browser: :chrome}] do
describe 'logs', except: [{browser: %i[firefox ie safari safari_preview]},
{driver: :remote, browser: %i[chrome edge]}] do
it 'can fetch remote log types', only: {driver: :remote} do
expect(driver.manage.logs.available_types).to include(:server, :browser, :driver)
end
Expand All @@ -43,7 +43,7 @@ module WebDriver
end

# Chrome - turned off by default
it 'can get the driver log', except: {browser: %i[chrome edge_chrome]} do
it 'can get the driver log', except: {browser: %i[chrome edge]} do
driver.navigate.to url_for('simpleTest.html')

entries = driver.manage.logs.get(:driver)
Expand All @@ -64,14 +64,14 @@ module WebDriver
expect(cookies.first[:value]).to eq('bar')
end

it 'should add sameSite cookie with attribute Strict', only: {browser: :chrome} do
it 'should add sameSite cookie with attribute Strict', only: {browser: %i[chrome edge]} do
driver.navigate.to url_for('xhtmlTest.html')
driver.manage.add_cookie name: 'foo', value: 'bar', same_site: 'Strict'

expect(driver.manage.cookie_named('foo')[:same_site]).to eq('Strict')
end

it 'should add sameSite cookie with attribute Lax', only: {browser: :chrome} do
it 'should add sameSite cookie with attribute Lax', only: {browser: %i[chrome edge]} do
driver.navigate.to url_for('xhtmlTest.html')
driver.manage.add_cookie name: 'foo', value: 'bar', same_site: 'Lax'
expect(driver.manage.cookie_named('foo')[:same_site]).to eq('Lax')
Expand All @@ -84,16 +84,15 @@ module WebDriver
expect(driver.manage.cookie_named('foo')[:value]).to eq('bar')
end

# Edge BUG - https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5751773/
it 'should delete one', except: {browser: :edge} do
it 'should delete one' do
driver.navigate.to url_for('xhtmlTest.html')
driver.manage.add_cookie name: 'foo', value: 'bar'

driver.manage.delete_cookie('foo')
expect(driver.manage.all_cookies.find { |c| c[:name] == 'foo' }).to be_nil
end

it 'should delete all', except: {browser: :edge} do
it 'should delete all' do
driver.navigate.to url_for('xhtmlTest.html')

driver.manage.add_cookie name: 'foo', value: 'bar'
Expand Down
Expand Up @@ -220,9 +220,9 @@ def create_safari_preview_driver(opt = {})
WebDriver::Driver.for :safari, opt
end

def create_edge_chrome_driver(opt = {})
def create_edge_driver(opt = {})
WebDriver::EdgeChrome.path = ENV['EDGE_BINARY'] if ENV['EDGE_BINARY']
WebDriver::Driver.for :edge_chrome, opt
WebDriver::Driver.for :edge, opt
end
end
end # SpecSupport
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/integration/selenium/webdriver/window_spec.rb
Expand Up @@ -75,7 +75,7 @@ module WebDriver
expect(new_pos.y).to eq(target_y)
end

it 'gets the rect of the current window', only: {browser: %i[edge edge_chrome firefox ie chrome safari safari_preview]} do
it 'gets the rect of the current window' do
rect = window.rect

expect(rect).to be_a(Rectangle)
Expand All @@ -86,7 +86,7 @@ module WebDriver
expect(rect.height).to be >= 0
end

it 'sets the rect of the current window', only: {browser: %i[edge_chrome firefox ie chrome safari safari_preview]} do
it 'sets the rect of the current window' do
rect = window.rect

target_x = rect.x + 10
Expand Down Expand Up @@ -120,7 +120,7 @@ module WebDriver
# https://github.com/mozilla/geckodriver/issues/1281
it 'can make window full screen', only: {window_manager: true},
exclude: [{driver: :remote, browser: :firefox, platform: :linux},
{browser: %i[chrome edge_chrome]}] do
{browser: %i[chrome edge]}] do
window.size = old_size = Dimension.new(700, 700)

window.full_screen
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/unit/selenium/webdriver/chrome/options_spec.rb
Expand Up @@ -232,7 +232,7 @@ module Chrome
'windowTypes' => %w[normal devtools]})
end
end
end # Options
end
end # Chrome
end # WebDriver
end # Selenium

0 comments on commit 444af06

Please sign in to comment.