Skip to content

Commit

Permalink
Added selenium window class
Browse files Browse the repository at this point in the history
  • Loading branch information
gedaiu committed Mar 6, 2016
1 parent 2144a18 commit d59013a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
61 changes: 61 additions & 0 deletions source/session.d
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
module selenium.session;

import selenium.api;


class SeleniumSession {

SeleniumApi api;

this(string serverUrl,
Capabilities desiredCapabilities,
Capabilities requiredCapabilities = Capabilities(),
Capabilities session = Capabilities()) {

api = SeleniumApi(serverUrl, desiredCapabilities, requiredCapabilities, session);
}

SeleniumWindow currentWindow() {
return new SeleniumWindow(api.windowHandle, api);
}

}

class SeleniumWindow {
string handle;
SeleniumApi api;

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

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

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

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

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

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

unittest {
auto session = new SeleniumSession("http://127.0.0.1:4444/wd/hub", Capabilities.chrome);

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;
}
4 changes: 2 additions & 2 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 @@ -185,5 +185,5 @@ unittest {
//session.applicationCacheStatus();
session.disconnect;
session.disconnect;+/
}

0 comments on commit d59013a

Please sign in to comment.