sourcegraph / go-selenium

Selenium WebDriver client for Go
https://sourcegraph.com/github.com/sourcegraph/go-selenium
Other
367 stars 73 forks source link

Element Screenshot #34

Closed guotie closed 7 years ago

guotie commented 7 years ago

webdriver has define element screenshot, in 18.2: https://www.w3.org/TR/webdriver/#take-element-screenshot

I have try as this:

func (elem *remoteWE) ScreenshotElement() ([]byte, error) {
data, err := elem.parent.stringCommand("/session/%s/element/" + elem.id + "/screenshot")
if err != nil {
    return nil, err
}

return []byte(data), nil
}

But i cannot work, error is 404 Not found, why?

sqs commented 7 years ago

Which webdriver version and browser (chrome, FF, etc.) are you using?

Sent from my iPhone

On Nov 23, 2016, at 20:13, 铁哥 notifications@github.com wrote:

webdriver has define element screenshot, in 18.2: https://www.w3.org/TR/webdriver/#take-element-screenshot

I have try as this:

func (elem *remoteWE) ScreenshotElement() ([]byte, error) { data, err := elem.parent.stringCommand("/session/%s/element/" + elem.id + "/screenshot") if err != nil { return nil, err }

return []byte(data), nil } But i cannot work, error is 404 Not found, why?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

guotie commented 7 years ago

chrome, 2.25

sqs commented 7 years ago

And you can confirm that version supports element screenshots? Can you cURL it or make it work with some other Selenium library?

Sent from my iPhone

On Nov 23, 2016, at 21:15, 铁哥 notifications@github.com wrote:

chrome, 2.25

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

guotie commented 7 years ago

I don't know whether it supports element screenshots.

I find the webdrive defined this protocol, but i did not see some example which use this api to obtain element screenshot.

Most examples is: 1 screenshot the page; 2 obtain the element's location & size; 3 crop the page screenshot in the element position.