-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters