Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some enhancements #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 66 additions & 7 deletions webdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ type Session struct {
}

type WindowHandle struct {
s *Session
id string
S *Session
Id string
}

type Size struct {
Expand Down Expand Up @@ -151,6 +151,65 @@ const (
CacheStatusObsolete = HTML5CacheStatus(5)
)

/* Keys */
const (
NullKey = string('\ue000')
CancelKey = string('\ue001')
HelpKey = string('\ue002')
BackspaceKey = string('\ue003')
TabKey = string('\ue004')
ClearKey = string('\ue005')
ReturnKey = string('\ue006')
EnterKey = string('\ue007')
ShiftKey = string('\ue008')
ControlKey = string('\ue009')
AltKey = string('\ue00a')
PauseKey = string('\ue00b')
EscapeKey = string('\ue00c')
SpaceKey = string('\ue00d')
PageUpKey = string('\ue00e')
PageDownKey = string('\ue00f')
EndKey = string('\ue010')
HomeKey = string('\ue011')
LeftArrowKey = string('\ue012')
UpArrowKey = string('\ue013')
RightArrowKey = string('\ue014')
DownArrowKey = string('\ue015')
InsertKey = string('\ue016')
DeleteKey = string('\ue017')
SemicolonKey = string('\ue018')
EqualsKey = string('\ue019')
Numpad0Key = string('\ue01a')
Numpad1Key = string('\ue01b')
Numpad2Key = string('\ue01c')
Numpad3Key = string('\ue01d')
Numpad4Key = string('\ue01e')
Numpad5Key = string('\ue01f')
Numpad6Key = string('\ue020')
Numpad7Key = string('\ue021')
Numpad8Key = string('\ue022')
Numpad9Key = string('\ue023')
MultiplyKey = string('\ue024')
AddKey = string('\ue025')
SeparatorKey = string('\ue026')
SubstractKey = string('\ue027')
DecimalKey = string('\ue028')
DivideKey = string('\ue029')
F1Key = string('\ue031')
F2Key = string('\ue032')
F3Key = string('\ue033')
F4Key = string('\ue034')
F5Key = string('\ue035')
F6Key = string('\ue036')
F7Key = string('\ue037')
F8Key = string('\ue038')
F9Key = string('\ue039')
F10Key = string('\ue03a')
F11Key = string('\ue03b')
F12Key = string('\ue03c')
MetaKey = string('\ue03d')
)

////////////////////////////////////////////////////////////////////////////////
// COMMAND LIST
// Command descriptions are from:
Expand Down Expand Up @@ -375,13 +434,13 @@ func (s Session) CloseCurrentWindow() error {
//Change the size of the specified window.
func (w WindowHandle) SetSize(size Size) error {
p := params{"width": size.Width, "height": size.Height}
_, _, err := w.s.wd.do(p, "POST", "/session/%s/window/%s/size", w.s.Id, w.id)
_, _, err := w.S.wd.do(p, "POST", "/session/%s/window/%s/size", w.S.Id, w.Id)
return err
}

//Get the size of the specified window.
func (w WindowHandle) GetSize() (Size, error) {
_, data, err := w.s.wd.do(nil, "GET", "/session/%s/window/%s/size", w.s.Id, w.id)
_, data, err := w.S.wd.do(nil, "GET", "/session/%s/window/%s/size", w.S.Id, w.Id)
if err != nil {
return Size{}, err
}
Expand All @@ -393,13 +452,13 @@ func (w WindowHandle) GetSize() (Size, error) {
//Change the position of the specified window.
func (w WindowHandle) SetPosition(position Position) error {
p := params{"x": position.X, "y": position.Y}
_, _, err := w.s.wd.do(p, "POST", "/session/%s/window/%s/position", w.s.Id, w.id)
_, _, err := w.S.wd.do(p, "POST", "/session/%s/window/%s/position", w.S.Id, w.Id)
return err
}

//Get the position of the specified window.
func (w WindowHandle) GetPosition() (Position, error) {
_, data, err := w.s.wd.do(nil, "GET", "/session/%s/window/%s/position", w.s.Id, w.id)
_, data, err := w.S.wd.do(nil, "GET", "/session/%s/window/%s/position", w.S.Id, w.Id)
if err != nil {
return Position{}, err
}
Expand All @@ -410,7 +469,7 @@ func (w WindowHandle) GetPosition() (Position, error) {

//Maximize the specified window if not already maximized.
func (w WindowHandle) MaximizeWindow() error {
_, _, err := w.s.wd.do(nil, "POST", "/session/%s/window/%s/maximize", w.s.Id, w.id)
_, _, err := w.S.wd.do(nil, "POST", "/session/%s/window/%s/maximize", w.S.Id, w.Id)
return err
}

Expand Down