-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put metadata into useragent for Firefox (#614)
This enables async tests while using the default selenium configuration.
- Loading branch information
Showing
4 changed files
with
94 additions
and
9 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.11.2-otp-21 | ||
erlang 21.3 | ||
erlang 23.3.4.4 |
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,68 @@ | ||
defmodule Wallaby.Integration.SeleniumCapabilitiesTest do | ||
use ExUnit.Case, async: false | ||
use Wallaby.DSL | ||
|
||
import Wallaby.SettingsTestHelpers | ||
|
||
alias Wallaby.Integration.SessionCase | ||
alias Wallaby.WebdriverClient | ||
|
||
setup do | ||
ensure_setting_is_reset(:wallaby, :selenium) | ||
end | ||
|
||
describe "capabilities" do | ||
test "reads default capabilities" do | ||
expected_capabilities = %{ | ||
javascriptEnabled: true, | ||
browserName: "firefox", | ||
"moz:firefoxOptions": %{ | ||
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 url, capabilities -> | ||
assert capabilities == expected_capabilities | ||
|
||
WebdriverClient.create_session(url, 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 = %{ | ||
browserName: "firefox", | ||
"moz:firefoxOptions": %{ | ||
args: ["-headless"] | ||
} | ||
} | ||
|
||
Application.put_env(:wallaby, :selenium, capabilities: expected_capabilities) | ||
|
||
create_session_fn = fn url, capabilities -> | ||
assert capabilities == expected_capabilities | ||
|
||
WebdriverClient.create_session(url, 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 | ||
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
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