trying to avoid flake on Okta login page in browser

This commit is contained in:
Ryan Richard 2023-09-19 08:58:22 -07:00
parent 62887a9cc8
commit cd1e4bacf8

View File

@ -209,13 +209,13 @@ func (b *Browser) AttrValueOfFirstMatch(t *testing.T, selector string, attribute
func (b *Browser) SendKeysToFirstMatch(t *testing.T, selector string, runesToType string) { func (b *Browser) SendKeysToFirstMatch(t *testing.T, selector string, runesToType string) {
t.Helper() t.Helper()
b.runWithTimeout(t, b.timeout(), chromedp.SendKeys(selector, runesToType, chromedp.NodeVisible)) b.runWithTimeout(t, b.timeout(), chromedp.SendKeys(selector, runesToType, chromedp.NodeVisible, chromedp.NodeEnabled))
} }
func (b *Browser) ClickFirstMatch(t *testing.T, selector string) string { func (b *Browser) ClickFirstMatch(t *testing.T, selector string) string {
t.Helper() t.Helper()
var text string var text string
b.runWithTimeout(t, b.timeout(), chromedp.Click(selector, chromedp.NodeVisible)) b.runWithTimeout(t, b.timeout(), chromedp.Click(selector, chromedp.NodeVisible, chromedp.NodeEnabled))
return text return text
} }
@ -336,6 +336,12 @@ func LoginToUpstreamOIDC(t *testing.T, b *Browser, upstream testlib.TestOIDCUpst
t.Logf("logging into %s", cfg.Name) t.Logf("logging into %s", cfg.Name)
b.SendKeysToFirstMatch(t, cfg.UsernameSelector, upstream.Username) b.SendKeysToFirstMatch(t, cfg.UsernameSelector, upstream.Username)
b.SendKeysToFirstMatch(t, cfg.PasswordSelector, upstream.Password) b.SendKeysToFirstMatch(t, cfg.PasswordSelector, upstream.Password)
// The Okta login page has a lot of Javascript on it. Give it a second to catch up after typing the
// username and password. Hoping that this might help with the test flake where the Okta login page
// never continues to the next page after trying to click the login button below.
time.Sleep(1 * time.Second)
b.ClickFirstMatch(t, cfg.LoginButtonSelector) b.ClickFirstMatch(t, cfg.LoginButtonSelector)
} }