From cb98b18259d433117ad07a2fbf78a7fdc636d991 Mon Sep 17 00:00:00 2001 From: hupe1980 Date: Tue, 21 Feb 2023 07:28:19 +0100 Subject: [PATCH] Misc --- element.go | 28 ++++++++++++++-------------- session.go | 18 +++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/element.go b/element.go index ddf5cf5..a1d290f 100644 --- a/element.go +++ b/element.go @@ -20,7 +20,7 @@ type Element struct { * https://www.w3.org/TR/webdriver/#elements * ****************************************************************************************************************/ -// Search for an element on the page, starting from the referenced web element. +// FindElement searches for an element on the page, starting from the referenced web element. func (e *Element) FindElement(strategy LocatorStrategy, selector string) (*Element, error) { data, err := e.client.Post(fmt.Sprintf("/session/%s/element/%s", e.SessionID, e.ID), &Params{ "using": strategy, @@ -38,7 +38,7 @@ func (e *Element) FindElement(strategy LocatorStrategy, selector string) (*Eleme return &Element{ID: webElement.ID, SessionID: e.SessionID, client: e.client}, nil } -// Search for multiple elements on the page, starting from the referenced web element. The located +// FindElements searches for multiple elements on the page, starting from the referenced web element. The located // elements will be returned as a WebElement JSON objects. The table below lists the locator // strategies that each server should support. Elements should be returned in the order located // in the DOM. @@ -64,7 +64,7 @@ func (e *Element) FindElements(strategy LocatorStrategy, selector string) ([]*El return elements, nil } -// Determines if the referenced element is selected or not. +// IsSelected determines if the referenced element is selected or not. // This operation only makes sense on input elements of the Checkbox- and Radio Button states, or on option elements. func (e *Element) IsSelected() (bool, error) { data, err := e.client.Get(fmt.Sprintf("/session/%s/element/%s/selected", e.SessionID, e.ID)) @@ -78,9 +78,9 @@ func (e *Element) IsSelected() (bool, error) { return selected, err } -// Returns the attribute value of the referenced web element. +// GetAttribute returns the attribute value of the referenced web element. func (e *Element) GetAttribute(name string) (string, error) { - data, err := e.client.Get(fmt.Sprintf("/session/%s/element/%s/attribure/%s", e.SessionID, e.ID, name)) + data, err := e.client.Get(fmt.Sprintf("/session/%s/element/%s/attribute/%s", e.SessionID, e.ID, name)) if err != nil { return "", err } @@ -91,7 +91,7 @@ func (e *Element) GetAttribute(name string) (string, error) { return value, err } -// Returns the property of the referenced web element. +// GetProperty returns the property of the referenced web element. func (e *Element) GetProperty(name string) (string, error) { data, err := e.client.Get(fmt.Sprintf("/session/%s/element/%s/property/%s", e.SessionID, e.ID, name)) if err != nil { @@ -104,8 +104,8 @@ func (e *Element) GetProperty(name string) (string, error) { return value, err } -// Returns the computed value of the given CSS property for the element. -func (e *Element) GetCSSValue(name string) (string, error) { +// GetCSS returns the computed value of the given CSS property for the element. +func (e *Element) GetCSS(name string) (string, error) { data, err := e.client.Get(fmt.Sprintf("/session/%s/element/%s/css/%s", e.SessionID, e.ID, name)) if err != nil { return "", err @@ -117,7 +117,7 @@ func (e *Element) GetCSSValue(name string) (string, error) { return value, err } -// Returns the visible text for the element. +// GetText returns the visible text for the element. func (e *Element) GetText() (string, error) { data, err := e.client.Get(fmt.Sprintf("/session/%s/element/%s/text", e.SessionID, e.ID)) if err != nil { @@ -130,7 +130,7 @@ func (e *Element) GetText() (string, error) { return text, err } -// Returns the tagName of a Element +// GetTagName returns the tagName of an element func (e *Element) GetTagName() (string, error) { data, err := e.client.Get(fmt.Sprintf("/session/%s/element/%s/name", e.SessionID, e.ID)) if err != nil { @@ -171,7 +171,7 @@ func (e *Element) GetRect() (*ElementRect, error) { return elementRect, err } -// Determines if the referenced element is enabled or not. +// IsEnabled determines if the referenced element is enabled or not. func (e *Element) IsEnabled() (bool, error) { data, err := e.client.Get(fmt.Sprintf("/session/%s/element/%s/enabled", e.SessionID, e.ID)) if err != nil { @@ -184,19 +184,19 @@ func (e *Element) IsEnabled() (bool, error) { return enabled, err } -// Click on an element. +// Click clicks on an element. func (e *Element) Click() error { _, err := e.client.Post(fmt.Sprintf("/session/%s/element/%s/click", e.SessionID, e.ID), nil) return err } -// Clear content of an element. +// Clear clears content of an element. func (e *Element) Clear() error { _, err := e.client.Post(fmt.Sprintf("/session/%s/element/%s/clear", e.SessionID, e.ID), nil) return err } -// Send a sequence of key strokes to an element. +// SendKeys sends a sequence of key strokes to an element. func (e *Element) SendKeys(text string) error { _, err := e.client.Post(fmt.Sprintf("/session/%s/element/%s/value", e.SessionID, e.ID), &Params{ "text": text, diff --git a/session.go b/session.go index 70ff56a..cb59e0d 100644 --- a/session.go +++ b/session.go @@ -30,7 +30,7 @@ type Timeouts struct { Implicit int `json:"implicit"` } -// Gets timeout durations associated with the current session. +// GetTimeouts gets timeout durations associated with the current session. func (s *Session) GetTimeouts() (*Timeouts, error) { data, err := s.client.Get(fmt.Sprintf("/session/%s/timeouts", s.ID)) if err != nil { @@ -43,7 +43,7 @@ func (s *Session) GetTimeouts() (*Timeouts, error) { return timeouts, err } -// Configure the amount of time that a particular type of operation can execute for before +// SetTimeouts configures the amount of time that a particular type of operation can execute for before // they are aborted and a Timeout error is returned to the client. func (s *Session) SetTimeouts(timeouts *Timeouts) error { _, err := s.client.Post(fmt.Sprintf("/session/%s/timeouts", s.ID), &Params{ @@ -60,7 +60,7 @@ func (s *Session) SetTimeouts(timeouts *Timeouts) error { * https://www.w3.org/TR/webdriver/#sessions * ****************************************************************************************************************/ -// Close the session. +// Close closes the session. func (s *Session) Close() error { _, err := s.client.Delete(fmt.Sprintf("/session/%s", s.ID)) return err @@ -71,13 +71,13 @@ func (s *Session) Close() error { * https://www.w3.org/TR/webdriver/#navigation * ****************************************************************************************************************/ -// Navigate to a new URL. +// NavigateTo navigates to a new URL. func (s *Session) NavigateTo(url string) error { _, err := s.client.Post(fmt.Sprintf("/session/%s/url", s.ID), &Params{"url": url}) return err } -// Get current page URL. +// GetCurrentURL gets current page URL. func (s *Session) GetCurrentURL() (string, error) { data, err := s.client.Get(fmt.Sprintf("/session/%s/url", s.ID)) if err != nil { @@ -90,25 +90,25 @@ func (s *Session) GetCurrentURL() (string, error) { return url, err } -// Navigate to previous url from history. +// Back navigates to previous url from history. func (s *Session) Back() error { _, err := s.client.Post(fmt.Sprintf("/session/%s/back", s.ID), nil) return err } -// Navigate forward to next url from history. +// Forward navigates forward to next url from history. func (s *Session) Forward() error { _, err := s.client.Post(fmt.Sprintf("/session/%s/forward", s.ID), nil) return err } -// Refresh the current page. +// Refresh refreshes the current page. func (s *Session) Refresh() error { _, err := s.client.Post(fmt.Sprintf("/session/%s/refresh", s.ID), nil) return err } -// Get the current page title. +// GetTitle gets the current page title. func (s *Session) GetTitle() (string, error) { data, err := s.client.Get(fmt.Sprintf("/session/%s/title", s.ID)) if err != nil {