tests clear old GitHub totp code before new one

Signed-off-by: Ryan Richard <richardry@vmware.com>
This commit is contained in:
Ryan Richard
2026-07-02 07:03:39 -07:00
parent a2d1ae5256
commit d8e5f4315c
+9
View File
@@ -271,6 +271,11 @@ func (b *Browser) SendKeysToFirstMatch(t *testing.T, cssSelector string, runesTo
b.runWithTimeout(t, b.timeout(), chromedp.SendKeys(cssSelector, runesToType, chromedp.NodeVisible, chromedp.NodeEnabled, chromedp.ByQuery))
}
func (b *Browser) ClearFirstMatch(t *testing.T, cssSelector string) {
t.Helper()
b.runWithTimeout(t, b.timeout(), chromedp.Clear(cssSelector, chromedp.NodeVisible, chromedp.NodeEnabled, chromedp.ByQuery))
}
func (b *Browser) ClickFirstMatch(t *testing.T, cssSelector string) string {
t.Helper()
var text string
@@ -449,6 +454,10 @@ func handleGithubOTPLoginPage(t *testing.T, b *Browser, upstream testlib.TestGit
t.Logf("waiting for GitHub MFA page")
b.WaitForVisibleElements(t, otpSelector)
// We may be in a loop where we are going to re-try entering the OTP code again on the same page,
// so first clear out any old OTP code that might be there from a previous attempt.
b.ClearFirstMatch(t, otpSelector)
// Sleep for a bit to make it less likely that we use the same OTP code twice when multiple tests are run in serial.
// GitHub gets upset when the same OTP code gets reused.
// GitHub seems to also get upset when any OTP codes are used often, like when all our GitHub tests run sequentially,