-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
753 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
elixir 1.18.1 | ||
elixir 1.17.3 | ||
erlang 27.2 |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Code.require_file("../tests.exs", __DIR__) | ||
|
||
# Additional test cases supported by selenium | ||
Code.require_file("../cases/browser/double_click_test.exs", __DIR__) | ||
Code.require_file("../cases/browser/frames_test.exs", __DIR__) | ||
Code.require_file("../cases/browser/hover_test.exs", __DIR__) | ||
Code.require_file("../cases/element/hover_test.exs", __DIR__) | ||
Code.require_file("../cases/browser/move_mouse_by_test.exs", __DIR__) | ||
Code.require_file("../cases/browser/window_handles_test.exs", __DIR__) | ||
Code.require_file("../cases/browser/window_position_test.exs", __DIR__) | ||
Code.require_file("../cases/element/size_test.exs", __DIR__) | ||
Code.require_file("../cases/element/location_test.exs", __DIR__) | ||
Code.require_file("../cases/feature/use_feature_test.exs", __DIR__) | ||
Code.require_file("../cases/feature/import_feature_test.exs", __DIR__) | ||
Code.require_file("../cases/feature/automatic_screenshot_test.exs", __DIR__) |
137 changes: 137 additions & 0 deletions
137
integration_test/selenium4/selenium4_capabilities_test.exs
This file contains 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 |
---|---|---|
@@ -0,0 +1,137 @@ | ||
defmodule Wallaby.Integration.Selenium4CapabilitiesTest do | ||
use ExUnit.Case, async: false | ||
use Wallaby.DSL | ||
|
||
import Wallaby.SettingsTestHelpers | ||
|
||
alias Wallaby.Integration.SessionCase | ||
|
||
setup do | ||
ensure_setting_is_reset(:wallaby, :selenium4) | ||
end | ||
|
||
describe "capabilities" do | ||
test "reads default capabilities" do | ||
expected_capabilities = %{ | ||
capabilities: %{ | ||
alwaysMatch: %{ | ||
browserName: "firefox", | ||
"moz:firefoxOptions": %{ | ||
binary: System.find_executable("firefox"), | ||
args: ["-headless"], | ||
prefs: %{ | ||
"general.useragent.override" => | ||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
create_session_fn = fn config, capabilities -> | ||
assert capabilities == expected_capabilities | ||
|
||
WebDriverClient.start_session(config, capabilities) | ||
end | ||
|
||
{:ok, session} = SessionCase.start_test_session(create_session_fn: create_session_fn) | ||
|
||
session | ||
|> visit("page_1.html") | ||
|> assert_has(Query.text("Page 1")) | ||
|
||
assert :ok = Wallaby.end_session(session) | ||
end | ||
|
||
test "reads capabilities from application config" do | ||
expected_capabilities = %{ | ||
capabilities: %{ | ||
alwaysMatch: %{ | ||
browserName: "firefox", | ||
"moz:firefoxOptions": %{ | ||
binary: System.find_executable("firefox"), | ||
args: ["-headless"] | ||
} | ||
} | ||
} | ||
} | ||
|
||
Application.put_env(:wallaby, :selenium4, capabilities: expected_capabilities) | ||
|
||
create_session_fn = fn config, capabilities -> | ||
assert capabilities == expected_capabilities | ||
|
||
WebDriverClient.start_session(config, capabilities) | ||
end | ||
|
||
{:ok, session} = SessionCase.start_test_session(create_session_fn: create_session_fn) | ||
|
||
session | ||
|> visit("page_1.html") | ||
|> assert_has(Query.text("Page 1")) | ||
|
||
assert :ok = Wallaby.end_session(session) | ||
end | ||
|
||
test "adds the beam metadata when it is present" do | ||
user_agent = "Mozilla/5.0" | ||
|
||
defined_capabilities = %{ | ||
capabilities: %{ | ||
alwaysMatch: %{ | ||
browserName: "firefox", | ||
"moz:firefoxOptions": %{ | ||
binary: System.find_executable("firefox"), | ||
args: ["-headless"], | ||
prefs: %{ | ||
"general.useragent.override" => user_agent | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
metadata = | ||
if Version.compare(System.version(), "1.16.0") in [:eq, :gt] do | ||
"g2gCdwJ2MXQAAAABbQAAAARzb21lbQAAAAhtZXRhZGF0YQ==" | ||
else | ||
"g2gCZAACdjF0AAAAAW0AAAAEc29tZW0AAAAIbWV0YWRhdGE=" | ||
end | ||
|
||
expected_capabilities = %{ | ||
capabilities: %{ | ||
alwaysMatch: %{ | ||
browserName: "firefox", | ||
"moz:firefoxOptions": %{ | ||
binary: System.find_executable("firefox"), | ||
args: ["-headless"], | ||
prefs: %{ | ||
"general.useragent.override" => "#{user_agent}/BeamMetadata (#{metadata})" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
Application.put_env(:wallaby, :selenium4, capabilities: defined_capabilities) | ||
|
||
create_session_fn = fn config, capabilities -> | ||
assert capabilities == expected_capabilities | ||
|
||
WebDriverClient.start_session(config, capabilities) | ||
end | ||
|
||
{:ok, session} = | ||
SessionCase.start_test_session( | ||
create_session_fn: create_session_fn, | ||
metadata: %{"some" => "metadata"} | ||
) | ||
|
||
session | ||
|> visit("page_1.html") | ||
|> assert_has(Query.text("Page 1")) | ||
|
||
assert :ok = Wallaby.end_session(session) | ||
end | ||
end | ||
end |
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ExUnit.configure(max_cases: 2, exclude: [pending: true]) | ||
|
||
# Load support files | ||
Code.require_file("../support/test_server.ex", __DIR__) | ||
Code.require_file("../support/pages/index_page.ex", __DIR__) | ||
Code.require_file("../support/pages/page_1.ex", __DIR__) | ||
Code.require_file("../support/session_case.ex", __DIR__) | ||
Code.require_file("../support/helpers.ex", __DIR__) | ||
|
||
{:ok, server} = Wallaby.Integration.TestServer.start() | ||
Application.put_env(:wallaby, :base_url, server.base_url) | ||
|
||
ExUnit.start() |
This file contains 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 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 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.