Documentation ¶
Overview ¶
Example ¶
// Example of Mozilla Firefox. // // geckodriver can be found in https://github.com/mozilla/geckodriver/releases w, err := selenium.NewWebDriver("geckodriver.exe") // If the path is not set, gecko driver cannot find the browser automaticly. // // In this situation, please use NewWebDriverWithBrowserBinary, for example: // w, err := selenium.NewWebDriver("geckodriver.exe", "C:/Program Files/Mozilla/firefox.exe") // if err != nil { log.Print("Fail of gecko driver") log.Fatal(err) return } defer w.Close() // To run the driver and to create a new session s, err := w.Run() if err != nil { log.Fatal(err) } s.Navigate("https://example.com")
Output:
Index ¶
- Variables
- type Element
- type Session
- func (s *Session) AddTab()
- func (s *Session) Close() error
- func (s *Session) CurrentPageTitle() string
- func (s *Session) CurrentURL() string
- func (s *Session) GetElementBySelectQuery(query string) (*Element, error)
- func (s *Session) GetElementByTagName(tagName string) (*Element, error)
- func (s *Session) GetElementByXPath(xpath string) (*Element, error)
- func (s *Session) GetElementsBySelectQuery(query string) ([]*Element, error)
- func (s *Session) GetElementsByTagName(tagName string) ([]*Element, error)
- func (s *Session) GetElementsByXPath(xpath string) ([]*Element, error)
- func (s *Session) Navigate(urlPath string) error
- func (s *Session) Screenshot(out io.Writer) error
- func (s *Session) SwitchToTab(tabIndex int) error
- func (s *Session) URL() *url.URL
- type WebDriver
- type WebDriverBody
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct { TagName string ID string // element ID attribute Class []string Role string Name string //element name attribute Type string //element name attribute // contains filtered or unexported fields }
HTML element
func (*Element) GetCSSValue ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func (*Session) Close ¶
Close the session
If it is already closed, the func will return ErrSessionClosed.
func (*Session) CurrentPageTitle ¶
func (*Session) CurrentURL ¶
Get current URL of the session.
If it has any error, this function will return "about:blank"
func (*Session) GetElementBySelectQuery ¶
To get the 1st element within the document that matches the query.
This is similar as document.querySelector() method in Javascript.
func (*Session) GetElementByTagName ¶
To get the 1st element within the document that matches the given tag name.
func (*Session) GetElementByXPath ¶
To get the 1st element within the document that matches the given XPath.
func (*Session) GetElementsBySelectQuery ¶
To get the elements within the document that matches the query.
This is similar as document.querySelectorAll() method in Javascript.
func (*Session) GetElementsByTagName ¶
To get the elements within the document that matches the the given tag name.
This is similar as document.getElementsByTagName() method or document.getElementsByTagNameNS() in Javascript.
func (*Session) GetElementsByXPath ¶
To get the elements within the document that matches the given XPath.
func (*Session) SwitchToTab ¶
type WebDriver ¶
type WebDriver struct { Sessions []*Session // contains filtered or unexported fields }