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

Get window size #125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SebastienBoisard
Copy link
Contributor

It can be useful to be able to get the browser window size.

So, I added 2 functions GetSize() in window.go and page.go (but I'm not sure to comply with method naming convention with GetSize() in page.go).

I tried to add some tests, I hope it's ok, but I'm not used to Ginkgo yet 😉.

@sclevine
Copy link
Owner

I merged the Element version of this before I noticed, but it appears that the /size and /location endpoints have been replaced with /rect endpoints for both element and window. I'm leaning towards merging this anyways, given that we already have SetSize, but we should probably introduce GetRect and SetRect for both element and window as well.

Height int `json:"height"`
}{}


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline

@@ -19,3 +19,17 @@ func (w *Window) SetSize(width, height int) error {

return w.Send("POST", "size", request, nil)
}

func (w *Window) GetSize() (width int, height int, err error) {
request := struct {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This struct does not represent a request


Describe("#GetSize", func() {
It("should successfully send a GET request to the size endpoint", func() {
width, height, err := window.GetSize()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setup and test return values using the mock bus (ideally in a separate test)

session.GetWindowCall.ReturnWindow = window
width, height, err := page.GetSize()
Expect(err).To(Succeed())
Expect(width).To(BeNumerically(">=", 0))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setup return values using the mock bus

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants