diff --git a/commands/metamask.js b/commands/metamask.js index 6f24d067f..48106f184 100644 --- a/commands/metamask.js +++ b/commands/metamask.js @@ -34,6 +34,7 @@ const { confirmationPageElements, } = require('../pages/metamask/confirmation-page'); const { + resetState, setNetwork, addNetwork, findNetwork, @@ -462,22 +463,18 @@ const metamask = { if (typeof network === 'string') { network = await findNetwork(network); } - // handle a case if network is already changed const currentNetwork = getCurrentNetwork(); if (network === currentNetwork) { return false; } - const networkAdded = await checkNetworkAdded(network); if (!networkAdded) { await module.exports.addNetwork(network); return true; } - await switchToMetamaskIfNotActive(); await playwright.waitAndClick(mainPageElements.networkSwitcher.button); - await playwright.waitAndClickByText( mainPageElements.networkSwitcher.dropdownMenuItem, network.name, @@ -642,13 +639,6 @@ const metamask = { await switchToCypressIfNotActive(); return true; }, - async activateAdvancedGasControl(skipSetup) { - return await activateAdvancedSetting( - advancedPageElements.advancedGasControlToggleOn, - advancedPageElements.advancedGasControlToggleOff, - skipSetup, - ); - }, async activateShowHexData(skipSetup) { return await activateAdvancedSetting( advancedPageElements.showHexDataToggleOn, @@ -864,11 +854,13 @@ const metamask = { .locator(notificationPageElements.customSpendingLimitInput) .count()) > 0 ) { - await playwright.waitAndSetValue( - spendLimit, - notificationPageElements.customSpendingLimitInput, - notificationPage, - ); + if (spendLimit) { + await playwright.waitAndSetValue( + spendLimit, + notificationPageElements.customSpendingLimitInput, + notificationPage, + ); + } await playwright.waitAndClick( notificationPageElements.allowToSpendButton, notificationPage, @@ -1128,7 +1120,7 @@ const metamask = { confirmPageElements.recipientButton, notificationPage, ); - txData.recipientPublicAddress = await playwright.waitAndGetValue( + txData.recipientPublicAddress = await playwright.waitAndGetInputValue( recipientPopupElements.recipientPublicAddress, notificationPage, ); @@ -1497,12 +1489,17 @@ const metamask = { await module.exports.getExtensionDetails(); await playwright.fixBlankPage(); await playwright.fixCriticalError(); + await resetState(); if ( (await playwright .metamaskWindow() .locator(onboardingWelcomePageElements.onboardingWelcomePage) .count()) > 0 ) { + await playwright.waitAndClick( + onboardingWelcomePageElements.onboardingTermsCheckbox, + await playwright.metamaskWindow(), + ); if (secretWordsOrPrivateKey.includes(' ')) { // secret words await module.exports.importWallet(secretWordsOrPrivateKey, password); @@ -1601,7 +1598,6 @@ async function setupSettings( ) { await switchToMetamaskIfNotActive(); await metamask.goToAdvancedSettings(); - await metamask.activateAdvancedGasControl(true); await metamask.activateShowHexData(true); await metamask.activateShowTestnetNetworks(true); await metamask.activateCustomNonce(true); diff --git a/pages/metamask/first-time-flow-page.js b/pages/metamask/first-time-flow-page.js index 41f3ba8f9..e0540039a 100644 --- a/pages/metamask/first-time-flow-page.js +++ b/pages/metamask/first-time-flow-page.js @@ -8,11 +8,13 @@ module.exports.metametricsPageElements = { const app = '#app-content .app'; const onboardingWelcomePage = `${onboardingFlow} [data-testid="onboarding-welcome"]`; +const onboardingTermsCheckbox = `${onboardingWelcomePage} [data-testid="onboarding-terms-checkbox"]`; const importWalletButton = `${onboardingWelcomePage} [data-testid="onboarding-import-wallet"]`; const createWalletButton = `${onboardingWelcomePage} [data-testid="onboarding-create-wallet"]`; module.exports.onboardingWelcomePageElements = { app, onboardingWelcomePage, + onboardingTermsCheckbox, importWalletButton, createWalletButton, }; diff --git a/pages/metamask/main-page.js b/pages/metamask/main-page.js index 06afa6c72..64cd2df7c 100644 --- a/pages/metamask/main-page.js +++ b/pages/metamask/main-page.js @@ -1,7 +1,7 @@ -const networkSwitcherButtonSelector = '.network-display'; +const networkSwitcherButtonSelector = '[data-testid="network-display"]'; const networkSwitcher = { button: networkSwitcherButtonSelector, - networkName: `${networkSwitcherButtonSelector} .typography`, + networkName: `${networkSwitcherButtonSelector} .mm-text--ellipsis`, dropdownMenu: '[data-testid="network-droppo"]', dropdownMenuItem: `[data-testid="network-droppo"] .dropdown-menu-item`, mainnetNetworkItem: `[data-testid="network-droppo"] [data-testid="mainnet-network-item"]`, @@ -74,8 +74,8 @@ const accountMenu = { const optionsMenu = { button: '[data-testid=account-options-menu-button]', - accountDetailsButton: '[data-testid="account-options-menu__account-details"]', - connectedSitesButton: '[data-testid="account-options-menu__connected-sites"]', + accountDetailsButton: '[data-testid="account-list-menu-details"]', + connectedSitesButton: '[data-testid="global-menu-connected-sites"]', }; const connectedSitesSelector = '.connected-sites'; @@ -87,10 +87,10 @@ const connectedSites = { closeButton: `${connectedSitesSelector} [data-testid="popover-close"]`, }; -const accountModalSelector = '.account-modal'; +const accountModalSelector = '.mm-modal-content__dialog'; const accountModal = { - walletAddressInput: `${accountModalSelector} .qr-code__address`, - closeButton: '.account-modal__close', + walletAddressInput: `${accountModalSelector} [data-testid="address-copy-button-text"]`, + closeButton: '.mm-button-icon[aria-label="Close"]', }; const renameAccount = { diff --git a/pages/metamask/notification-page.js b/pages/metamask/notification-page.js index ccac8014c..3bcc303d1 100644 --- a/pages/metamask/notification-page.js +++ b/pages/metamask/notification-page.js @@ -2,12 +2,12 @@ const notificationPage = '.notification'; const notificationAppContent = `${notificationPage} #app-content .app`; const loadingLogo = `${notificationPage} #loading__logo`; const loadingSpinner = `${notificationPage} #loading__spinner`; -const nextButton = `${notificationPage} .permissions-connect-choose-account__bottom-buttons .btn-primary`; +const nextButton = `${notificationPage} [data-testid="page-container-footer-next"]`; const cancelButton = `${notificationPage} .permissions-connect-choose-account__bottom-buttons .btn-secondary`; const customSpendingLimitInput = `${notificationPage} [data-testid="custom-spending-cap-input"]`; const allowToSpendButton = `${notificationPage} [data-testid="page-container-footer-next"]`; const rejectToSpendButton = `${notificationPage} [data-testid="page-container-footer-cancel"]`; -const selectAllCheckbox = `${notificationPage} .choose-account-list__header-check-box`; +const selectAllCheckbox = `${notificationPage} [data-testid="choose-account-list-operate-all-check-box"]`; const approveWarningToSpendButton = `${notificationPage} .set-approval-for-all-warning__footer__approve-button`; const rejectWarningToSpendButton = `${notificationPage} .btn-secondary.set-approval-for-all-warning__footer__cancel-button`; @@ -50,10 +50,10 @@ module.exports.permissionsPageElements = { connectButton, }; -const popupContainer = '.popover-container'; -const popupCloseButton = `${popupContainer} .popover-header__button`; -const popupCopyRecipientPublicAddressButton = `${popupContainer} .nickname-popover__public-address button`; -const recipientPublicAddress = `${popupContainer} .nickname-popover__public-address__constant`; +const popupContainer = '.mm-modal'; +const popupCloseButton = `${popupContainer} [aria-label="Close"]`; +const popupCopyRecipientPublicAddressButton = `${popupContainer} [aria-label="Copy address to clipboard"]`; +const recipientPublicAddress = `${popupContainer} .mm-text-field--disabled input`; module.exports.recipientPopupElements = { popupContainer, popupCloseButton, diff --git a/pages/metamask/settings-page.js b/pages/metamask/settings-page.js index ba4390b87..22f89d29f 100644 --- a/pages/metamask/settings-page.js +++ b/pages/metamask/settings-page.js @@ -11,22 +11,18 @@ module.exports.settingsPageElements = { const resetAccountButton = '[data-testid="advanced-setting-reset-account"] button'; -const advancedGasControlToggleOn = - '[data-testid="advanced-setting-advanced-gas-inline"] .toggle-button--on'; -const advancedGasControlToggleOff = - '[data-testid="advanced-setting-advanced-gas-inline"] .toggle-button--off'; const showHexDataToggleOn = '[data-testid="advanced-setting-hex-data"] .toggle-button--on'; const showHexDataToggleOff = '[data-testid="advanced-setting-hex-data"] .toggle-button--off'; const showTestnetConversionOn = - '[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(6) .toggle-button--on'; + '[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(4) .toggle-button--on'; const showTestnetConversionOff = - '[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(6) .toggle-button--off'; + '[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(4) .toggle-button--off'; const showTestnetNetworksOn = - '[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(7) .toggle-button--on'; + '[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(5) .toggle-button--on'; const showTestnetNetworksOff = - '[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(7) .toggle-button--off'; + '[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(5) .toggle-button--off'; const customNonceToggleOn = '[data-testid="advanced-setting-custom-nonce"] .toggle-button--on'; const customNonceToggleOff = @@ -41,8 +37,6 @@ const ethSignRequestsToggleOff = '[data-testid="advanced-setting-toggle-ethsign"] .toggle-button--off'; module.exports.advancedPageElements = { resetAccountButton, - advancedGasControlToggleOn, - advancedGasControlToggleOff, showHexDataToggleOn, showHexDataToggleOff, showTestnetConversionOn, @@ -80,7 +74,7 @@ const addNetworkForm = '.networks-tab__add-network-form-body'; const networkNameInput = `${addNetworkForm} .form-field:nth-child(1) input`; const rpcUrlInput = `${addNetworkForm} .form-field:nth-child(2) input`; const chainIdInput = `${addNetworkForm} .form-field:nth-child(3) input`; -const symbolInput = `${addNetworkForm} .form-field:nth-child(4) input`; +const symbolInput = `${addNetworkForm} [data-testid="network-form-ticker"] input`; const blockExplorerInput = `${addNetworkForm} .form-field:nth-child(5) input`; const saveButton = '.networks-tab__add-network-form-footer .btn-primary'; module.exports.addNetworkPageElements = {