Skip to content

Commit

Permalink
Merge pull request #3 from groove-x/feature/windowsize
Browse files Browse the repository at this point in the history
add method of changing windows size
  • Loading branch information
uzuna authored Jul 31, 2019
2 parents a5ff347 + 1ccf3b0 commit 8a6aff4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,17 @@ func (b *Browser) ExpectTransitTo(rawurl string) *Browser {
}
return b
}



func (b *Browser) SetWindowSize(width,height int) {
b.session.GetCurrentWindowHandle().SetSize(webdriver.Size{width,height})
}

func (b *Browser) GetWindowSize()(width,height int, err error) {
size,err := b.session.GetCurrentWindowHandle().GetSize()
if err != nil {
return
}
return size.Width,size.Height, nil
}
5 changes: 3 additions & 2 deletions example/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"
"time"

"github.com/atotto/webtester"
"github.com/atotto/webtester/chrome"
"github.com/groove-x/webtester"
"github.com/groove-x/webtester/chrome"
)

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -60,6 +60,7 @@ func TestPlayground(t *testing.T) {
defer ts.TearDown()

b := ts.OpenBrowser()
b.SetWindowSize(1600,1200)
b.SetPageLoadTimeout(2 * time.Second)

b.VisitTo("https://play.golang.org/")
Expand Down

0 comments on commit 8a6aff4

Please sign in to comment.