Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Feb 21, 2023
1 parent 5040c04 commit cb98b18
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
28 changes: 14 additions & 14 deletions element.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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))
Expand All @@ -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
}
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit cb98b18

Please sign in to comment.