Skip to content

Commit

Permalink
Merge pull request #35 from stuart/feature/elixir-1.1.1
Browse files Browse the repository at this point in the history
Updates for Elixir 1.1.1 and updated Firefox plugin
  • Loading branch information
stuart committed Dec 21, 2015
2 parents 5298d6c + fe7130c commit 9886f65
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 27 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ notifications:
otp_release:
- 17.0
env:
- ELIXIR="v0.15.1"
- ELIXIR="v1.1.1"

before_install:
- mkdir -p vendor/elixir
Expand Down
Binary file added Elixir.WebDriver.Firefox.Profile.beam
Binary file not shown.
3 changes: 2 additions & 1 deletion lib/webdriver/firefox/profile.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ defmodule WebDriver.Firefox.Profile do
{"browser.startup.page", 0},
{"browser.tabs.warnOnClose", false},
{"browser.tabs.warnOnOpen", false},
{"browser.selfsupport.url", ""},
{"devtools.errorconsole.enabled", true},
{"dom.disable_open_during_load", false},
{"dom.max_chrome_script_run_time", 30},
Expand Down Expand Up @@ -58,7 +59,7 @@ defmodule WebDriver.Firefox.Profile do
{"webdriver_accept_untrusted_certs", true},
{"webdriver_assume_untrusted_issuer", true},
{"webdriver_enable_native_events", false},
{"webdriver.log.file", "/tmp/log/webdriver.log"}
{"webdriver.log.file", "/tmp/webdriver.log"}
]

@webdriver_prefs [
Expand Down
6 changes: 3 additions & 3 deletions lib/webdriver/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -850,11 +850,11 @@ defmodule WebDriver.Protocol do
try do
case request.method do
:GET ->
HTTPotion.get(request.url, request.headers)
HTTPotion.get(request.url, [headers: request.headers])
:POST ->
HTTPotion.post(request.url, request.body, request.headers)
HTTPotion.post(request.url, [body: request.body, headers: request.headers])
:DELETE ->
HTTPotion.delete(request.url, request.headers)
HTTPotion.delete(request.url, [headers: request.headers])
end |> handle_response(root_url) |> add_request(request)
rescue
[HTTPotion.HTTPError, :econnrefused] ->
Expand Down
6 changes: 3 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ defmodule WebDriver.Mixfile do
# { :foobar, "0.1", git: "https://github.com/elixir-lang/foobar.git" }
defp deps do
[
{:ibrowse, github: "cmullaparthi/ibrowse", tag: "v4.1.0"},
{:httpotion, "~> 0.2.4"},
{:jazz, "~> 0.2.0"},
{:ibrowse, github: "cmullaparthi/ibrowse", tag: "v4.1.2"},
{:httpotion, "~> 2.1"},
{:jazz, "~> 0.2.1"},
{:mock, github: "jjh42/mock", only: :test},
{:earmark, "~>0.1.10", only: :dev},
{:ex_doc, "~>0.6", only: :dev}
Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
%{"earmark": {:hex, :earmark, "0.1.10"},
"ex_doc": {:hex, :ex_doc, "0.6.1"},
"hoedown": {:git, "git://github.com/hoedown/hoedown.git", "34d28b5f1af41a8879985f2550ddcaa54c4e432b", []},
"httpotion": {:hex, :httpotion, "0.2.4"},
"ibrowse": {:git, "git://github.com/cmullaparthi/ibrowse.git", "7871e2ebe8811efb64e1917e2de455fa87e8dfe3", [tag: "v4.1.0"]},
"jazz": {:hex, :jazz, "0.2.0"},
"httpotion": {:hex, :httpotion, "2.1.0"},
"ibrowse": {:git, "https://github.com/cmullaparthi/ibrowse.git", "ea3305d21f37eced4fac290f64b068e56df7de80", [tag: "v4.1.2"]},
"jazz": {:hex, :jazz, "0.2.1"},
"jsonex": {:git, "git://github.com/marcelog/jsonex.git", "82e6c416eed5e791073427bf3079d7ab7b85a1e1", []},
"jsx": {:git, "git://github.com/talentdeficit/jsx.git", "507fa4c41db33c81e925ab53f4d789d234aaff2f", []},
"markdown": {:git, "git://github.com/devinus/markdown.git", "a428908a6dd88f351775d1d3da530a1a2aa0d6cb", []},
Expand Down
Binary file modified plugins/firefox/webdriver.xpi
Binary file not shown.
15 changes: 10 additions & 5 deletions test/webdriver/chrome_session_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ defmodule WebDriverChromeSessionTest do

test "a non existing element" do
Session.url :cdtest, "http://localhost:8888/page_1.html"
assert nil = Session.element :cdtest, :tag, "nothing"
assert nil == Session.element :cdtest, :tag, "nothing"
end

test "find an element starting from a specified element" do
Expand Down Expand Up @@ -309,6 +309,7 @@ defmodule WebDriverChromeSessionTest do
Session.url :cdtest, "http://localhost:8888/page_1.html"
element = Session.element :cdtest, :link, "Back to Index"
assert {:ok, _} = Element.click element
:timer.sleep(100)
assert "http://localhost:8888/index.html" = Session.url :cdtest
end

Expand Down Expand Up @@ -464,24 +465,28 @@ defmodule WebDriverChromeSessionTest do
assert resp.status == 0
end

test "alert_text" do
test "alert_text" do
Session.url :cdtest, "http://localhost:8888/alert.html"
Session.element(:cdtest, :id, "alert") |> Element.click
# It seems that the alert takes a while to be available
:timer.sleep(100)
assert "this is an alert" = Session.alert_text(:cdtest)
Session.accept_alert :cdtest
end
end

test "setting text in a prompt" do
test "setting text in a prompt" do
Session.url :cdtest, "http://localhost:8888/alert.html"
Session.element(:cdtest, :id, "prompt") |> Element.click
:timer.sleep(100)
Session.alert_text(:cdtest, "Stuart")
Session.accept_alert :cdtest
assert "Hello Stuart" = Session.element(:cdtest, :id, "result") |> Element.text
end
end

test "dismissing a prompt" do
Session.url :cdtest, "http://localhost:8888/alert.html"
Session.element(:cdtest, :id, "prompt") |> Element.click
:timer.sleep(100)
Session.alert_text(:cdtest, "Stuart")
Session.dismiss_alert :cdtest
assert "" = Session.element(:cdtest, :id, "result") |> Element.text
Expand Down
1 change: 1 addition & 0 deletions test/webdriver/firefox/profile_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defmodule FirefoxProfileTest do
tempdir = Profile.make_temp_directory
on_exit fn ->
File.rm_rf tempdir
System.cmd("killall", ["firefox-bin"])
end
{:ok, [tempdir: tempdir]}
end
Expand Down
2 changes: 1 addition & 1 deletion test/webdriver/firefox_session_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ defmodule WebDriverFirefoxSessionTest do

test "a non existing element" do
Session.url :fftest, "http://localhost:8888/page_1.html"
assert nil = Session.element :fftest, :tag, "nothing"
assert nil == Session.element :fftest, :tag, "nothing"
end

test "find an element starting from a specified element" do
Expand Down
2 changes: 1 addition & 1 deletion test/webdriver/phantomjs_session_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ defmodule WebDriverPhantomJSSessionTest do

test "a non existing element" do
Session.url :test, "http://localhost:8888/page_1.html"
assert nil = Session.element :test, :tag, "nothing"
assert nil == Session.element :test, :tag, "nothing"
end

test "find an element starting from a specified element" do
Expand Down
19 changes: 10 additions & 9 deletions test/webdriver/protocol_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -415,39 +415,40 @@ defmodule WebDriverProtocolTest do
# Mocks a response to a request.
# The response just echoes the request body.
def test_get command, path do
with_mock HTTPotion, [], [get: fn(url, headers) -> get(url, headers) end] do
with_mock HTTPotion, [], [get: fn(url, options) -> get(url, options) end] do
{:ok, _response} = command.("http://127.0.0.1:8080")
assert_get path
end
end

def test_post command, path, body do
with_mock HTTPotion, [], [post: fn(url, params, headers) -> post(url, params, headers) end] do
def test_post command, path, options do
with_mock HTTPotion, [], [post: fn(url, options) -> post(url, options) end] do
{:ok, _response} = command.("http://127.0.0.1:8080")
assert_post path, body
assert_post path, options
end
end

def test_delete command, path do
with_mock HTTPotion, [], [delete: fn(url, headers) -> delete(url, headers) end] do
with_mock HTTPotion, [], [delete: fn(url, options) -> delete(url, options) end] do
{:ok, _response} = command.("http://127.0.0.1:8080")
assert_delete path
end
end

def post(_url, body, _headers) do
def post(_url, options) do
body = Keyword.get(options, :body)
%HTTPotion.Response{ body: "{\"sessionId\": \"1234\", \"status\": 0, \"value\": #{JSON.encode! body}}",
status_code: 201, headers: []}
end

# Mocks a response to a GET request. Just returns an HTTPotion Response
def get(_url, _headers) do
def get(_url, _options) do
%HTTPotion.Response{ body: "{\"sessionId\": \"1234\", \"status\": 0, \"value\": #{JSON.encode!(%{})}}",
status_code: 200, headers: [] }
end

# Mocks a response to a DELETE request. Just returns an HTTPotion Response
def delete(_url, _headers) do
def delete(_url, _options) do
%HTTPotion.Response{ body: "{\"sessionId\": \"1234\", \"status\": 0, \"value\": #{JSON.encode!(%{})}}",
status_code: 204, headers: [] }
end
Expand All @@ -459,7 +460,7 @@ defmodule WebDriverProtocolTest do
defp assert_post path, body do
# Jazz shuffles map keys around.
b = JSON.decode!(body) |> JSON.encode!
assert called HTTPotion.post("http://127.0.0.1:8080#{path}", b, :_)
assert called HTTPotion.post("http://127.0.0.1:8080#{path}", :_)
end

defp assert_delete path do
Expand Down

0 comments on commit 9886f65

Please sign in to comment.