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

Get window size#125

Open
SebastienBoisard wants to merge 2 commits into
sclevine:masterfrom
SebastienBoisard:get_window_size
Open

Get window size#125
SebastienBoisard wants to merge 2 commits into
sclevine:masterfrom
SebastienBoisard:get_window_size

Conversation

@SebastienBoisard

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread api/window.go
Height int `json:"height"`
}{}


Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Remove newline

Comment thread api/window.go
}

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

Copy link
Copy Markdown
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

Comment thread api/window_test.go

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

Copy link
Copy Markdown
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)

Comment thread page_test.go
session.GetWindowCall.ReturnWindow = window
width, height, err := page.GetSize()
Expect(err).To(Succeed())
Expect(width).To(BeNumerically(">=", 0))

Copy link
Copy Markdown
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