From fa9353ea7c2b1e0f58a844590571682c837b3eee Mon Sep 17 00:00:00 2001 From: Alexey Kontsevoy Date: Wed, 23 Nov 2016 19:18:58 -0500 Subject: [PATCH] Allow to create a page using existing SessionURL closes #91 --- api/session.go | 5 +++++ page.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/api/session.go b/api/session.go index b30db2a..021382d 100644 --- a/api/session.go +++ b/api/session.go @@ -17,6 +17,11 @@ type Bus interface { Send(method, endpoint string, body, result interface{}) error } +func New(sessionURL string) *Session { + busClient := &bus.Client{sessionURL, http.DefaultClient} + return &Session{busClient} +} + func Open(url string, capabilities map[string]interface{}) (*Session, error) { return OpenWithClient(url, capabilities, nil) } diff --git a/page.go b/page.go index ad01a61..012d74c 100644 --- a/page.go +++ b/page.go @@ -48,6 +48,12 @@ func NewPage(url string, options ...Option) (*Page, error) { return newPage(session), nil } +// JoinPage creates a Page using existing session URL. +func JoinPage(url string) *Page { + session := api.New(url) + return newPage(session) +} + func newPage(session *api.Session) *Page { return &Page{selectable{session, nil}, nil} }