From 6ba73ce2b0258ec5f2f41bbe47015d95c566a39f Mon Sep 17 00:00:00 2001 From: Stuart Coyle Date: Mon, 18 Aug 2014 08:05:38 +1000 Subject: [PATCH] Test tweaks --- test/webdriver/chrome_session_test.exs | 19 +++++++++---------- test/webdriver/firefox_session_test.exs | 4 ++-- test/webdriver/phantomjs_session_test.exs | 16 ++++++++-------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/test/webdriver/chrome_session_test.exs b/test/webdriver/chrome_session_test.exs index 9907dd1..15b924d 100644 --- a/test/webdriver/chrome_session_test.exs +++ b/test/webdriver/chrome_session_test.exs @@ -145,12 +145,11 @@ defmodule WebDriverChromeSessionTest do assert {:no_such_window, _} = Session.window :cdtest, "xyz" end - # Close window destroys the session on chrome - # test "close window" do - # WebDriver.start_session :cdtest_browser, :window_close - # assert {:ok, _} = Session.close_window :window_close - # WebDriver.stop_session :window_close - # end + test "close window" do + WebDriver.start_session :chrome_test_browser, :window_close + assert {:ok, _} = Session.close_window :window_close + WebDriver.stop_session :window_close + end test "window size" do size = Session.window_size :cdtest @@ -204,7 +203,8 @@ defmodule WebDriverChromeSessionTest do Session.url :cdtest, "http://example.com/index.html" cookie = %WebDriver.Cookie{name: "name", value: "value", path: "/", domain: "example.com"} Session.set_cookie :cdtest, cookie - Session.delete_cookie :cdtest, "name" + # This is a bit flakey. It seems Chrome takes a bit of time to delete the cookie but returns immediately. + {:ok, _} = Session.delete_cookie :cdtest, "name" assert [ _ ] = Session.cookies :cdtest end @@ -285,10 +285,10 @@ defmodule WebDriverChromeSessionTest do assert [] = Session.elements :cdtest, :tag, "none" end - # FIXME Not implemented on chrome? + # Not implemented on chrome # test "active element" do # Session.url :cdtest, "http://localhost:8888/page_1.html" - # assert is_element? Session.active_element :cdtest + # assert is_element? = Session.active_element :cdtest # end test "get orientation" do @@ -468,7 +468,6 @@ defmodule WebDriverChromeSessionTest do end - # Check that a request returns {ok, response} and the response status is 0 defp check func, params \\ [] do assert_response :erlang.apply Session, func, [:cdtest | params] diff --git a/test/webdriver/firefox_session_test.exs b/test/webdriver/firefox_session_test.exs index 7d50d7c..156ab27 100644 --- a/test/webdriver/firefox_session_test.exs +++ b/test/webdriver/firefox_session_test.exs @@ -266,10 +266,10 @@ defmodule WebDriverFirefoxSessionTest do end #FIXME: firefox does not support this - #test "active element" do + # test "active element" do # Session.url :fftest, "http://localhost:8888/page_1.html" # assert is_element? Session.active_element :fftest - #end + # end test "get orientation" do assert {:error, "Session does not support device rotation."} == Session.orientation(:fftest) diff --git a/test/webdriver/phantomjs_session_test.exs b/test/webdriver/phantomjs_session_test.exs index c685b1b..6d4b0ea 100644 --- a/test/webdriver/phantomjs_session_test.exs +++ b/test/webdriver/phantomjs_session_test.exs @@ -142,19 +142,19 @@ defmodule WebDriverPhantomJSSessionTest do assert <<137,80,78,71,13,10,26,10,_ :: binary >> = :base64.decode(Session.screenshot :test) end - # test "no such frame error" do - # assert {:no_such_frame, _ } = Session.frame :test, 123 - # end - # + test "no such frame error" do + assert {:no_such_frame, _ } = Session.frame :test, 123 + end + test "window" do handle = Session.window_handle :test check :window, [handle] end - # test "error when there is no such window" do - # assert {:no_such_window, _} = Session.window :test, "xyz" - # end - # + test "error when there is no such window" do + assert {:no_such_window, _} = Session.window :test, "xyz" + end + test "close window" do WebDriver.start_session :test_browser, :window_close assert {:ok, _} = Session.close_window :window_close