Skip to content

Commit b3575ff

Browse files
committed
Merge pull request #29 from stuart/feature/hex_dependencies
Feature/hex dependencies
2 parents 6ba73ce + ebc74ef commit b3575ff

23 files changed

Lines changed: 277 additions & 167 deletions

.DS_Store

6 KB
Binary file not shown.

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@ before_install:
1515
- "export DISPLAY=:99.0"
1616
- "sh -e /etc/init.d/xvfb start"
1717

18-
before_script: "export PATH=$PATH:`pwd`/vendor/elixir/bin"
18+
before_script:
19+
- "export PATH=$PATH:`pwd`/vendor/elixir/bin"
20+
- mix local.hex --force;
21+
1922
script: "MIX_ENV=test mix do deps.get, deps.compile, test"

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Web Driver for Elixir
22
[![Build Status](https://travis-ci.org/stuart/elixir-webdriver.png?branch=master)](https://travis-ci.org/stuart/elixir-webdriver)
33

4-
[Current Version 0.5.0](https://github.com/stuart/elixir-webdriver/tree/0.5.0)
4+
[Current Version 0.6.0](https://github.com/stuart/elixir-webdriver/tree/0.6.0)
55

66
This is an implementation of the WebDriver protocol client.
77
It currently supports PhantomJS, FireFox, ChromeDriver and remote webdriver
@@ -100,7 +100,22 @@ Currently I have only tested extensively on OSX, and Ubuntu Linux.
100100
It should work on most UNIX like platforms. There is some rudimentary
101101
Windows support code in here, but I'm pretty sure that it won't work.
102102

103+
## Support
104+
Please report any issues you have with using this library in the Github
105+
issues for the project:
106+
https://github.com/stuart/elixir-webdriver/issues
107+
108+
103109
## Changelog
110+
111+
* 2014-08-18
112+
- Version 0.6.0
113+
- Changed JSON library to Jazz
114+
- Converted responses to be maps rather than Keywords
115+
- Use hex.pm dependencies as much as possible
116+
- Stability fixes to tests
117+
- Documentation updates and cleanup.
118+
104119
* 2014-08-17
105120
- Version 0.5.2
106121
- Moved webdriver.xpi out of hex accessed path

lib/webdriver/browser.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
defmodule WebDriver.Browser do
22
@moduledoc """
33
This is the basic skeleton for a Browser port to control a browser.
4-
Implementations will need to use this and then implement the other required
5-
functions.
4+
Implementations for specific browsers will need to use this
5+
and then implement the other required functionality.
66
"""
77
defmacro __using__(_opts) do
88
quote do

lib/webdriver/browser_sup.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ defmodule WebDriver.BrowserSup do
66
the running of browser instances and their associated session supervisors.
77
88
If a browser crashes for any reason this will restart the browser and the
9-
sessions that connect to it.
9+
sessions that connect to it. Of course those sessions will have lost their
10+
state.
1011
"""
1112

1213
@browsers [ firefox: WebDriver.Firefox.Port,

lib/webdriver/cookie.ex

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ defmodule WebDriver.Cookie do
44
A module for querying and manipulation of cookies.
55
Cookies are defined in a struct with the following fields:
66
7-
- name
8-
- value
9-
- path
10-
- domain
11-
- secure
12-
- expiry
7+
* `name`
8+
* `value`
9+
* `path`
10+
* `domain`
11+
* `secure`
12+
* `expiry`
1313
1414
"""
15+
16+
@doc """
17+
Creates a cookie struct from a webdriver response.
18+
"""
1519
def from_response cookie do
1620
struct(WebDriver.Cookie, Enum.map(cookie, fn({k,v}) -> {String.to_atom(k),v} end))
1721
end

lib/webdriver/element.ex

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ defmodule WebDriver.Element do
44
55
They all take an WebDriver.Element struct as the first argument.
66
The WebDriver.Element struct is supposed to be an opaque data type and
7-
is not meant to be manipulated.
7+
is not meant to be manipulated. It contains the internal id of the element
8+
used by the webdriver client and a the session name.
89
910
Elements are associated with a particular session and have no meaning
1011
outside that WedDriver session.
@@ -51,10 +52,10 @@ defmodule WebDriver.Element do
5152
5253
https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/:id/value
5354
54-
Parameters: [value: String]
55+
Parameters: %{value: String}
5556
"""
5657
def value element, value do
57-
cmd element, :value, [value: String.codepoints value]
58+
cmd element, :value, %{value: String.codepoints value}
5859
end
5960

6061
@doc """
@@ -77,7 +78,7 @@ defmodule WebDriver.Element do
7778

7879
@doc """
7980
Returns a boolean denoting if the element is selected or not.
80-
Returns :element_not_selectable if it is not able to be selected.
81+
Returns {:element_not_selectable, response} if it is not able to be selected.
8182
8283
https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/selected
8384
"""
@@ -131,16 +132,16 @@ defmodule WebDriver.Element do
131132
132133
https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/location
133134
134-
Returns [x: x, y: y]
135+
Returns %{x: x, y: y}
135136
"""
136137
def location element do
137138
case get_value element, :location do
138139
# Bug with Python Selenium
139140
# http://code.google.com/p/selenium/source/detail?r=bbcfab457b13
140-
[{"toString",_},{"x",x},{"y",y}] ->
141-
[x: x, y: y]
142-
[{"x",x},{"y",y}] ->
143-
[x: x, y: y]
141+
%{"toString" => _,"x" => x,"y" => y} ->
142+
%{x: x, y: y}
143+
%{"x" => x, "y" => y} ->
144+
%{x: x, y: y}
144145
response -> # Pass error responses through.
145146
response
146147
end
@@ -151,7 +152,7 @@ defmodule WebDriver.Element do
151152
152153
https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/location_in_view
153154
154-
Returns [x: x, y: y]
155+
Returns %{x: x, y: y}
155156
"""
156157
def location_in_view element do
157158
do_location_in_view(get_value(element, :location))
@@ -164,18 +165,15 @@ defmodule WebDriver.Element do
164165
defp do_location_in_view response do
165166
# Bugfix
166167
# http://code.google.com/p/selenium/source/detail?r=bbcfab457b13
167-
resp = Enum.into response, HashDict.new
168-
{:ok, x} = HashDict.fetch(resp,"x")
169-
{:ok, y} = HashDict.fetch(resp,"y")
170-
[x: x, y: y]
168+
%{x: response["x"], y: response["y"]}
171169
end
172170

173171
@doc """
174172
Returns size in pixels of the specified element.
175173
176174
https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/size
177175
178-
Returns [width: w, height: h]
176+
Returns %{width: w, height: h}
179177
"""
180178
def size element do
181179
do_size(get_value(element, :size))
@@ -186,10 +184,7 @@ defmodule WebDriver.Element do
186184
end
187185

188186
defp do_size response do
189-
resp = Enum.into response, HashDict.new
190-
{:ok, h} = HashDict.fetch(resp,"height")
191-
{:ok, w} = HashDict.fetch(resp,"width")
192-
[width: w, height: h]
187+
%{width: response["width"], height: response["height"]}
193188
end
194189

195190
@doc """

lib/webdriver/error.ex

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,32 @@ defmodule WebDriver.Error do
3636
3737
The codes that can be returned are:
3838
39-
39+
* :success
40+
* :no_such_driver
41+
* :no_such_element
42+
* :no_such_frame
43+
* :unknown_command
44+
* :stale_element_reference
45+
* :element_not_visible
46+
* :invalid_element_state
47+
* :unknown_error
48+
* :element_not_selectable
49+
* :javascript_error
50+
* :x_path_lookup_error
51+
* :timeout
52+
* :no_such_window
53+
* :invalid_cookie_domain
54+
* :unable_to_set_cookie
55+
* :unexpected_alert_open
56+
* :no_alert_open_error
57+
* :script_timeout
58+
* :invalid_element_coordinates
59+
* :ime_not_available
60+
* :ime_engine_activation_failed
61+
* :invalid_selector
62+
* :session_not_created_exception
63+
* :move_target_out_of_bounds
64+
4065
"""
4166

4267
defmodule ErrorMessage do

lib/webdriver/http/http.ex

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/webdriver/keys.ex

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
defmodule WebDriver.Keys do
2+
@moduledoc """
3+
This provides symbols to represent various non-printable keystrokes that
4+
can be sent to a web browser.
5+
6+
The codes are defined in: https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value
7+
8+
"""
29
@non_text_keys [
310
{ :key_null, "\x{e000}" },
411
{ :key_cancel, "\x{e001}"},
@@ -73,6 +80,64 @@ defmodule WebDriver.Keys do
7380
7481
Key codes that are available:
7582
83+
```Elixir
84+
{ :key_null, "\x{e000}"},
85+
{ :key_cancel, "\x{e001}"},
86+
{ :key_help, "\x{e002}"},
87+
{ :key_back_space,"\x{e003}"},
88+
{ :key_tab, "\x{e004}"},
89+
{ :key_clear, "\x{e005}"},
90+
{ :key_return, "\x{e006}"},
91+
{ :key_enter, "\x{e007}"},
92+
{ :key_shift, "\x{e008}"},
93+
{ :key_control, "\x{e009}"},
94+
{ :key_alt, "\x{e00a}"},
95+
{ :key_pause, "\x{e00b}"},
96+
{ :key_escape, "\x{e00c}"},
97+
{ :key_space, "\x{e00d}"},
98+
{ :key_page_up, "\x{e00e}"},
99+
{ :key_page_down, "\x{e00f}"},
100+
{ :key_end, "\x{e010}"},
101+
{ :key_home, "\x{e011}"},
102+
{ :key_left, "\x{e012}"},
103+
{ :key_up, "\x{e013}"},
104+
{ :key_right, "\x{e014}"},
105+
{ :key_down, "\x{e015}"},
106+
{ :key_insert, "\x{e016}"},
107+
{ :key_delete, "\x{e017}"},
108+
{ :key_semicolon, "\x{e018}"},
109+
{ :key_equals, "\x{e019}"},
110+
{ :key_numpad_0, "\x{e01a}"},
111+
{ :key_numpad_1, "\x{e01b}"},
112+
{ :key_numpad_2, "\x{e01c}"},
113+
{ :key_numpad_3, "\x{e01d}"},
114+
{ :key_numpad_4, "\x{e01e}"},
115+
{ :key_numpad_5, "\x{e01f}"},
116+
{ :key_numpad_6, "\x{e020}"},
117+
{ :key_numpad_7, "\x{e021}"},
118+
{ :key_numpad_8, "\x{e022}"},
119+
{ :key_numpad_9, "\x{e023}"},
120+
{ :key_multiply, "\x{e024}"},
121+
{ :key_add, "\x{e025}"},
122+
{ :key_separator, "\x{e026}"},
123+
{ :key_subtract, "\x{e027}"},
124+
{ :key_decimal, "\x{e028}"},
125+
{ :key_divide, "\x{e029}"},
126+
{ :key_f1, "\x{e031}"},
127+
{ :key_f2, "\x{e032}"},
128+
{ :key_f3, "\x{e033}"},
129+
{ :key_f4, "\x{e034}"},
130+
{ :key_f5, "\x{e035}"},
131+
{ :key_f6, "\x{e036}"},
132+
{ :key_f7, "\x{e037}"},
133+
{ :key_f8, "\x{e038}"},
134+
{ :key_f9, "\x{e039}"},
135+
{ :key_f10, "\x{e03a}"},
136+
{ :key_f11, "\x{e03b}"},
137+
{ :key_f12, "\x{e03c}"},
138+
{ :key_meta, "\x{e03d}"}
139+
140+
```
76141
"""
77142
def key key_code do
78143
Keyword.fetch(@non_text_keys, key_code)

0 commit comments

Comments
 (0)