Skip to content

Commit

Permalink
wait longer for tests to start (#1568)
Browse files Browse the repository at this point in the history
* wait longer

* tweak
  • Loading branch information
romainmenke committed May 26, 2023
1 parent aeee9f8 commit 1db27a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions scripts/browserstack/selenium.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,15 @@ func runSeleniumTest(wd selenium.WebDriver, port int, test Test) Test {
}

// First check if the page loaded and has our content before waiting for async tests
err = wd.WaitWithTimeoutAndInterval(selenium.Condition(func(wd1 selenium.WebDriver) (bool, error) {
return getBoolFromWebDriver(wd1, `return (typeof window.testLoaded !== "undefined");`)
}), time.Second*60, time.Second)
if err != nil {
test.end = time.Now()
test.err = err
return test
}

loaded, err := getBoolFromWebDriver(wd, `return window.testLoaded;`)
if err != nil {
test.end = time.Now()
Expand Down
6 changes: 3 additions & 3 deletions scripts/browserstack/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type WorkerConfig struct {
}

func (x *Client) NewWorker(parentCtx context.Context, config WorkerConfig) (*Worker, error) {
ctx, cancel := context.WithTimeout(parentCtx, time.Second*5)
ctx, cancel := context.WithTimeout(parentCtx, time.Second*10)
defer cancel()

params := map[string]interface{}{}
Expand Down Expand Up @@ -165,7 +165,7 @@ func (x *Client) NewWorker(parentCtx context.Context, config WorkerConfig) (*Wor
}

func (x *Client) DeleteWorker(parentCtx context.Context, id int) (bool, error) {
ctx, cancel := context.WithTimeout(parentCtx, time.Second*5)
ctx, cancel := context.WithTimeout(parentCtx, time.Second*10)
defer cancel()

req, err := http.NewRequestWithContext(ctx, http.MethodDelete, fmt.Sprintf("https://api.browserstack.com/5/worker/%d", id), nil)
Expand Down Expand Up @@ -207,7 +207,7 @@ func (x *Client) DeleteWorker(parentCtx context.Context, id int) (bool, error) {
}

func (x *Client) Workers(parentCtx context.Context) ([]*Worker, error) {
ctx, cancel := context.WithTimeout(parentCtx, time.Second*5)
ctx, cancel := context.WithTimeout(parentCtx, time.Second*10)
defer cancel()

req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://api.browserstack.com/5/workers", nil)
Expand Down

0 comments on commit 1db27a1

Please sign in to comment.