Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #95 from alex-kovoy/join_existing_session
Browse files Browse the repository at this point in the history
Allow to create a page using existing SessionURL
  • Loading branch information
sclevine authored Nov 24, 2016
2 parents fc7e3d5 + fa9353e commit da6ce95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 6 additions & 0 deletions page.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down

0 comments on commit da6ce95

Please sign in to comment.