Skip to content

Commit

Permalink
Removed position api
Browse files Browse the repository at this point in the history
  • Loading branch information
gedaiu committed Mar 6, 2016
1 parent d59013a commit 1e90fde
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 40 deletions.
21 changes: 6 additions & 15 deletions source/api.d
Original file line number Diff line number Diff line change
Expand Up @@ -352,26 +352,17 @@ struct SeleniumApi {
return this;
}

auto windowSize(string handle, Size size) {
POST("/window/" ~ handle ~ "/size", size);
auto windowSize(Size size) {
POST("/window/size", size);
return this;
}

auto windowSize(string handle) {
return GET!Size("/window/" ~ handle ~ "/size");
auto windowSize() {
return GET!Size("/window/size");
}

auto windowPosition(string handle, Position position) {
POST("/window/" ~ handle ~ "/position", position);
return this;
}

auto windowPosition(string handle) {
return GET!Position("/window/" ~ handle ~ "/position");
}

auto windowMaximize(string handle) {
POST("/window/" ~ handle ~ "/maximize");
auto windowMaximize() {
POST("/window/maximize");
return this;
}

Expand Down
26 changes: 8 additions & 18 deletions source/session.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import selenium.api;


class SeleniumSession {

SeleniumApi api;

this(string serverUrl,
Expand All @@ -18,36 +17,30 @@ class SeleniumSession {
SeleniumWindow currentWindow() {
return new SeleniumWindow(api.windowHandle, api);
}

}

class SeleniumWindow {
string handle;
SeleniumApi api;

protected {
string handle;
SeleniumApi api;
}

this(string handle, SeleniumApi api) {
this.handle = handle;
this.api = api;
}

Size size() {
return api.windowSize(handle);
return api.windowSize;
}

void size(Size value) {
api.windowSize(handle, value);
}

Position position() {
return api.windowPosition(handle);
}

void position(Position value) {
api.windowPosition(handle, value);
api.windowSize(value);
}

void maximize() {
api.windowMaximize(handle);
api.windowMaximize;
}
}

Expand All @@ -57,8 +50,5 @@ unittest {
session.currentWindow.size = Size(400, 500);
assert(session.currentWindow.size == Size(400, 500));

session.currentWindow.position = Position(100, 200);
assert(session.currentWindow.position == Position(100, 200));

session.currentWindow.maximize;
}
12 changes: 5 additions & 7 deletions source/test.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import vibe.data.json;

import std.datetime;

unittest {/+
unittest {
auto url1 = "http://www.amazon.com/All-Light-We-Cannot-See/dp/1476746583/";
auto url2 = "http://www.amazon.com/The-Boys-Boat-Americans-Olympics/dp/0143125478/";

Expand Down Expand Up @@ -50,12 +50,10 @@ unittest {/+
//session.selectWindow("testOpen");
//session.closeCurrentWindow();

assert(session.windowSize(handle, Size(400, 500)).windowSize(handle) == Size(400, 500));
assert(session.windowPosition(handle, Position(100, 200)).windowPosition(handle) == Position(100, 200));
assert(session.windowSize(Size(400, 500)).windowSize == Size(400, 500));

session.windowMaximize(handle);
assert(session.windowSize(handle) != Size(400, 500));
assert(session.windowPosition(handle) != Position(100, 200));
session.windowMaximize;
assert(session.windowSize != Size(400, 500));

assert(session.cookie.length > 0);

Expand Down Expand Up @@ -185,5 +183,5 @@ unittest {/+

//session.applicationCacheStatus();

session.disconnect;+/
session.disconnect;
}

0 comments on commit 1e90fde

Please sign in to comment.