Skip to content

Commit

Permalink
Stabilize e2e tests for phishing detection (#21152)
Browse files Browse the repository at this point in the history
## **Description**
Several e2e testcases about phishing detection are flaky.

## **Why they are flaky?**
After investigation, i think because when we open a malicious website,
selenium fetch very quickly all the DOM elements and consider they are
complete. When the page redirects to phishing detection page, it dose
not re-fetch elements so selenium cannot find buttons to click.

## **How i resolve it?**
I explicitly force selenium to switch to the phishing detection page
each time after redirection so it will re-fetch all elements on this
page.

## **Why do i think the fix works**
For each testcase, I ran locally 20 times and they all passed.

Fixes #21150
  • Loading branch information
chloeYue authored Oct 3, 2023
1 parent be3aa42 commit 0139b99
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/e2e/tests/phishing-controller/phishing-detection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('Phishing Detection', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await openDapp(driver);
await driver.switchToWindowWithTitle('MetaMask Phishing Detection');
await driver.clickElement({
text: 'continue to the site.',
});
Expand Down Expand Up @@ -177,6 +178,7 @@ describe('Phishing Detection', function () {
await driver.press('#password', driver.Key.ENTER);
await openDapp(driver);

await driver.switchToWindowWithTitle('MetaMask Phishing Detection');
await driver.clickElement({ text: 'report a detection problem.' });

// wait for page to load before checking URL.
Expand Down Expand Up @@ -215,6 +217,7 @@ describe('Phishing Detection', function () {
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage(phishingSite.href);

await driver.switchToWindowWithTitle('MetaMask Phishing Detection');
await driver.clickElement({ text: 'report a detection problem.' });

// wait for page to load before checking URL.
Expand Down Expand Up @@ -252,6 +255,7 @@ describe('Phishing Detection', function () {
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080');

await driver.switchToWindowWithTitle('MetaMask Phishing Detection');
await driver.clickElement({ text: 'report a detection problem.' });

// wait for page to load before checking URL.
Expand Down

0 comments on commit 0139b99

Please sign in to comment.