How to use rejectDataSignatureRequest method in synthetixio-synpress

Best JavaScript code snippet using synthetixio-synpress

metamask.js

Source:metamask.js Github

copy

Full Screen

1const playwright = require('./playwright');2const {3 welcomePageElements,4 firstTimeFlowPageElements,5 metametricsPageElements,6 firstTimeFlowFormPageElements,7 secureYourWalletPageElements,8 revealSeedPageElements,9 endOfFlowPageElements,10} = require('../pages/metamask/first-time-flow-page');11const { mainPageElements } = require('../pages/metamask/main-page');12const { unlockPageElements } = require('../pages/metamask/unlock-page');13const {14 notificationPageElements,15 permissionsPageElements,16 confirmPageElements,17 signaturePageElements,18 encryptionPublicKeyPageElements,19 decryptPageElements,20 dataSignaturePageElements,21} = require('../pages/metamask/notification-page');22const {23 settingsPageElements,24 advancedPageElements,25 resetAccountModalElements,26 networksPageElements,27 addNetworkPageElements,28} = require('../pages/metamask/settings-page');29const {30 confirmationPageElements,31} = require('../pages/metamask/confirmation-page');32const { setNetwork, getNetwork } = require('../support/helpers');33let extensionInitialUrl;34let extensionId;35let extensionHomeUrl;36let extensionSettingsUrl;37let extensionAdvancedSettingsUrl;38let extensionAddNetworkUrl;39let extensionNewAccountUrl;40let extensionImportAccountUrl;41let walletAddress;42let switchBackToCypressWindow;43module.exports = {44 extensionId: () => {45 return extensionId;46 },47 extensionUrls: () => {48 return {49 extensionInitialUrl,50 extensionHomeUrl,51 extensionSettingsUrl,52 extensionAdvancedSettingsUrl,53 extensionAddNetworkUrl,54 extensionNewAccountUrl,55 extensionImportAccountUrl,56 };57 },58 walletAddress: () => {59 return walletAddress;60 },61 goToSettings: async () => {62 await Promise.all([63 playwright.metamaskWindow().waitForNavigation(),64 playwright.metamaskWindow().goto(extensionSettingsUrl),65 ]);66 },67 goToAdvancedSettings: async () => {68 await Promise.all([69 playwright.metamaskWindow().waitForNavigation(),70 playwright.metamaskWindow().goto(extensionAdvancedSettingsUrl),71 ]);72 },73 goToAddNetwork: async () => {74 await Promise.all([75 playwright.metamaskWindow().waitForNavigation(),76 playwright.metamaskWindow().goto(extensionAddNetworkUrl),77 ]);78 },79 goToNewAccount: async () => {80 await Promise.all([81 playwright.metamaskWindow().waitForNavigation(),82 playwright.metamaskWindow().goto(extensionNewAccountUrl),83 ]);84 },85 goToImportAccount: async () => {86 await Promise.all([87 playwright.metamaskWindow().waitForNavigation(),88 playwright.metamaskWindow().goto(extensionImportAccountUrl),89 ]);90 },91 getExtensionDetails: async () => {92 extensionInitialUrl = await playwright.metamaskWindow().url();93 extensionId = extensionInitialUrl.match('//(.*?)/')[1];94 extensionHomeUrl = `chrome-extension://${extensionId}/home.html`;95 extensionSettingsUrl = `${extensionHomeUrl}#settings`;96 extensionAdvancedSettingsUrl = `${extensionSettingsUrl}/advanced`;97 extensionAddNetworkUrl = `${extensionSettingsUrl}/networks/add-network`;98 extensionNewAccountUrl = `${extensionHomeUrl}#new-account`;99 extensionImportAccountUrl = `${extensionNewAccountUrl}/import`;100 return {101 extensionInitialUrl,102 extensionId,103 extensionSettingsUrl,104 extensionAdvancedSettingsUrl,105 extensionAddNetworkUrl,106 extensionNewAccountUrl,107 extensionImportAccountUrl,108 };109 },110 // workaround for metamask random blank page on first run111 fixBlankPage: async () => {112 await playwright.metamaskWindow().waitForTimeout(1000);113 for (let times = 0; times < 5; times++) {114 if (115 (await playwright.metamaskWindow().$(welcomePageElements.app)) === null116 ) {117 await playwright.metamaskWindow().reload();118 await playwright.metamaskWindow().waitForTimeout(2000);119 } else {120 break;121 }122 }123 },124 confirmWelcomePage: async () => {125 await module.exports.fixBlankPage();126 await playwright.waitAndClick(127 welcomePageElements.confirmButton,128 await playwright.metamaskWindow(),129 {130 waitForEvent: 'navi',131 },132 );133 return true;134 },135 closePopup: async () => {136 // note: this is required for fast execution of e2e tests to avoid flakiness137 // otherwise popup may not be detected properly and not closed138 await playwright.metamaskWindow().waitForTimeout(1000);139 if (140 (await playwright141 .metamaskWindow()142 .$(mainPageElements.popup.container)) !== null143 ) {144 const popupBackground = playwright145 .metamaskWindow()146 .locator(mainPageElements.popup.background);147 const popupBackgroundBox = await popupBackground.boundingBox();148 await playwright149 .metamaskWindow()150 .mouse.click(popupBackgroundBox.x + 1, popupBackgroundBox.y + 1);151 }152 return true;153 },154 closeModal: async () => {155 // note: this is required for fast execution of e2e tests to avoid flakiness156 // otherwise modal may not be detected properly and not closed157 await playwright.metamaskWindow().waitForTimeout(1000);158 if (159 (await playwright160 .metamaskWindow()161 .$(mainPageElements.connectedSites.modal)) !== null162 ) {163 await playwright.waitAndClick(164 mainPageElements.connectedSites.closeButton,165 );166 }167 return true;168 },169 unlock: async password => {170 await module.exports.fixBlankPage();171 await playwright.waitAndType(unlockPageElements.passwordInput, password);172 await playwright.waitAndClick(173 unlockPageElements.unlockButton,174 await playwright.metamaskWindow(),175 {176 waitForEvent: 'navi',177 },178 );179 await module.exports.closePopup();180 return true;181 },182 importWallet: async (secretWords, password) => {183 await playwright.waitAndClick(184 firstTimeFlowPageElements.importWalletButton,185 await playwright.metamaskWindow(),186 {187 waitForEvent: 'navi',188 },189 );190 await playwright.waitAndClick(191 metametricsPageElements.optOutAnalyticsButton,192 await playwright.metamaskWindow(),193 {194 waitForEvent: 'navi',195 },196 );197 await playwright.waitAndType(198 firstTimeFlowFormPageElements.secretWordsInput,199 secretWords,200 );201 await playwright.waitAndType(202 firstTimeFlowFormPageElements.passwordInput,203 password,204 );205 await playwright.waitAndType(206 firstTimeFlowFormPageElements.confirmPasswordInput,207 password,208 );209 await playwright.waitAndClick(firstTimeFlowFormPageElements.termsCheckbox);210 await playwright.waitAndClick(211 firstTimeFlowFormPageElements.importButton,212 await playwright.metamaskWindow(),213 {214 waitForEvent: 'navi',215 },216 );217 await playwright.waitAndClick(218 endOfFlowPageElements.allDoneButton,219 await playwright.metamaskWindow(),220 {221 waitForEvent: 'navi',222 },223 );224 await module.exports.closePopup();225 return true;226 },227 createWallet: async password => {228 await playwright.waitAndClick(229 firstTimeFlowPageElements.createWalletButton,230 await playwright.metamaskWindow(),231 {232 waitForEvent: 'navi',233 },234 );235 await playwright.waitAndClick(236 metametricsPageElements.optOutAnalyticsButton,237 await playwright.metamaskWindow(),238 {239 waitForEvent: 'navi',240 },241 );242 await playwright.waitAndType(243 firstTimeFlowFormPageElements.newPasswordInput,244 password,245 );246 await playwright.waitAndType(247 firstTimeFlowFormPageElements.confirmPasswordInput,248 password,249 );250 await playwright.waitAndClick(251 firstTimeFlowFormPageElements.newSignupCheckbox,252 );253 await playwright.waitAndClick(254 firstTimeFlowFormPageElements.importButton,255 await playwright.metamaskWindow(),256 {257 waitForEvent: 'navi',258 },259 );260 await playwright.waitAndClick(261 secureYourWalletPageElements.nextButton,262 await playwright.metamaskWindow(),263 {264 waitForEvent: 'navi',265 },266 );267 await playwright.waitAndClick(268 revealSeedPageElements.remindLaterButton,269 await playwright.metamaskWindow(),270 {271 waitForEvent: 'navi',272 },273 );274 await module.exports.closePopup();275 return true;276 },277 importAccount: async privateKey => {278 await switchToMetamaskIfNotActive();279 await module.exports.goToImportAccount();280 await playwright.waitAndType(281 mainPageElements.importAccount.input,282 privateKey,283 );284 await playwright.waitAndClick(285 mainPageElements.importAccount.importButton,286 await playwright.metamaskWindow(),287 {288 waitForEvent: 'navi',289 },290 );291 await switchToCypressIfNotActive();292 return true;293 },294 createAccount: async accountName => {295 if (accountName) {296 accountName = accountName.toLowerCase();297 }298 await switchToMetamaskIfNotActive();299 await module.exports.goToNewAccount();300 if (accountName) {301 await playwright.waitAndType(302 mainPageElements.createAccount.input,303 accountName,304 );305 }306 await playwright.waitAndClick(mainPageElements.createAccount.createButton);307 await switchToCypressIfNotActive();308 return true;309 },310 switchAccount: async accountNameOrAccountNumber => {311 if (typeof accountNameOrAccountNumber === 'string') {312 accountNameOrAccountNumber = accountNameOrAccountNumber.toLowerCase();313 }314 await switchToMetamaskIfNotActive();315 // note: closePopup() is required after changing createAccount() to use direct urls (popup started appearing)316 // ^ this change also introduced 500ms delay for closePopup() function317 await module.exports.closePopup();318 await playwright.waitAndClick(mainPageElements.accountMenu.button);319 if (typeof accountNameOrAccountNumber === 'number') {320 await playwright.waitAndClick(321 mainPageElements.accountMenu.accountButton(accountNameOrAccountNumber),322 );323 } else {324 await playwright.waitAndClickByText(325 mainPageElements.accountMenu.accountName,326 accountNameOrAccountNumber,327 );328 }329 await switchToCypressIfNotActive();330 return true;331 },332 changeNetwork: async network => {333 await switchToMetamaskIfNotActive();334 if (typeof network === 'string') {335 network = network.toLowerCase();336 } else if (typeof network === 'object') {337 network.networkName = network.networkName.toLowerCase();338 }339 await playwright.waitAndClick(mainPageElements.networkSwitcher.button);340 if (network === 'main' || network === 'mainnet') {341 await playwright.waitAndClick(342 mainPageElements.networkSwitcher.networkButton(0),343 );344 } else if (network === 'ropsten') {345 await playwright.waitAndClick(346 mainPageElements.networkSwitcher.networkButton(1),347 );348 } else if (network === 'kovan') {349 await playwright.waitAndClick(350 mainPageElements.networkSwitcher.networkButton(2),351 );352 } else if (network === 'rinkeby') {353 await playwright.waitAndClick(354 mainPageElements.networkSwitcher.networkButton(3),355 );356 } else if (network === 'goerli') {357 await playwright.waitAndClick(358 mainPageElements.networkSwitcher.networkButton(4),359 );360 } else if (network === 'localhost') {361 await playwright.waitAndClick(362 mainPageElements.networkSwitcher.networkButton(5),363 );364 } else if (typeof network === 'object') {365 await playwright.waitAndClickByText(366 mainPageElements.networkSwitcher.dropdownMenuItem,367 network.networkName,368 );369 } else {370 await playwright.waitAndClickByText(371 mainPageElements.networkSwitcher.dropdownMenuItem,372 network,373 );374 }375 setNetwork(network);376 if (typeof network === 'object') {377 await playwright.waitForText(378 mainPageElements.networkSwitcher.networkName,379 network.networkName,380 );381 } else {382 await playwright.waitForText(383 mainPageElements.networkSwitcher.networkName,384 network,385 );386 }387 await switchToCypressIfNotActive();388 return true;389 },390 addNetwork: async network => {391 await switchToMetamaskIfNotActive();392 if (393 process.env.NETWORK_NAME &&394 process.env.RPC_URL &&395 process.env.CHAIN_ID396 ) {397 network = {398 networkName: process.env.NETWORK_NAME,399 rpcUrl: process.env.RPC_URL,400 chainId: process.env.CHAIN_ID,401 symbol: process.env.SYMBOL,402 blockExplorer: process.env.BLOCK_EXPLORER,403 isTestnet: process.env.IS_TESTNET,404 };405 }406 if (typeof network === 'string') {407 network = network.toLowerCase();408 } else if (typeof network === 'object') {409 network.networkName = network.networkName.toLowerCase();410 }411 await module.exports.goToAddNetwork();412 await playwright.waitAndClick(networksPageElements.addNetworkButton);413 await playwright.waitAndType(414 addNetworkPageElements.networkNameInput,415 network.networkName,416 );417 await playwright.waitAndType(418 addNetworkPageElements.rpcUrlInput,419 network.rpcUrl,420 );421 await playwright.waitAndType(422 addNetworkPageElements.chainIdInput,423 network.chainId,424 );425 if (network.symbol) {426 await playwright.waitAndType(427 addNetworkPageElements.symbolInput,428 network.symbol,429 );430 }431 if (network.blockExplorer) {432 await playwright.waitAndType(433 addNetworkPageElements.blockExplorerInput,434 network.blockExplorer,435 );436 }437 await playwright.waitAndClick(addNetworkPageElements.saveButton);438 await playwright.waitAndClick(439 settingsPageElements.closeButton,440 await playwright.metamaskWindow(),441 {442 waitForEvent: 'navi',443 },444 );445 setNetwork(network);446 await playwright.waitForText(447 mainPageElements.networkSwitcher.networkName,448 network.networkName,449 );450 await switchToCypressIfNotActive();451 return true;452 },453 async disconnectWalletFromDapp() {454 await switchToMetamaskIfNotActive();455 await playwright.waitAndClick(mainPageElements.optionsMenu.button);456 await playwright.waitAndClick(457 mainPageElements.optionsMenu.connectedSitesButton,458 );459 const trashButton = await playwright460 .metamaskWindow()461 .$(mainPageElements.connectedSites.trashButton);462 if (trashButton) {463 console.log(464 '[disconnectWalletFromDapp] Wallet is connected to a dapp, disconnecting..',465 );466 await playwright.waitAndClick(467 mainPageElements.connectedSites.trashButton,468 );469 await playwright.waitAndClick(470 mainPageElements.connectedSites.disconnectButton,471 );472 } else {473 console.log(474 '[disconnectWalletFromDapp] Wallet is not connected to a dapp, skipping..',475 );476 }477 await module.exports.closeModal();478 await switchToCypressIfNotActive();479 return true;480 },481 async disconnectWalletFromAllDapps() {482 await switchToMetamaskIfNotActive();483 await playwright.waitAndClick(mainPageElements.optionsMenu.button);484 await playwright.waitAndClick(485 mainPageElements.optionsMenu.connectedSitesButton,486 );487 const trashButtons = await playwright488 .metamaskWindow()489 .$$(mainPageElements.connectedSites.trashButton);490 if (trashButtons.length) {491 console.log(492 '[disconnectWalletFromAllDapps] Wallet is connected to dapps, disconnecting..',493 );494 // eslint-disable-next-line no-unused-vars495 for (const trashButton of trashButtons) {496 await playwright.waitAndClick(497 mainPageElements.connectedSites.trashButton,498 );499 await playwright.waitAndClick(500 mainPageElements.connectedSites.disconnectButton,501 );502 }503 } else {504 console.log(505 '[disconnectWalletFromAllDapps] Wallet is not connected to any dapps, skipping..',506 );507 }508 await module.exports.closeModal();509 await switchToCypressIfNotActive();510 return true;511 },512 activateCustomNonce: async () => {513 await switchToMetamaskIfNotActive();514 await module.exports.goToAdvancedSettings();515 if (516 (await playwright517 .metamaskWindow()518 .$(advancedPageElements.customNonceToggleOn)) === null519 ) {520 await playwright.waitAndClick(advancedPageElements.customNonceToggleOff);521 }522 await playwright.waitAndClick(523 settingsPageElements.closeButton,524 await playwright.metamaskWindow(),525 {526 waitForEvent: 'navi',527 },528 );529 await switchToCypressIfNotActive();530 return true;531 },532 resetAccount: async () => {533 await switchToMetamaskIfNotActive();534 await module.exports.goToAdvancedSettings();535 await playwright.waitAndClick(advancedPageElements.resetAccountButton);536 await playwright.waitAndClick(resetAccountModalElements.resetButton);537 await playwright.waitAndClick(538 settingsPageElements.closeButton,539 await playwright.metamaskWindow(),540 {541 waitForEvent: 'navi',542 },543 );544 await switchToCypressIfNotActive();545 return true;546 },547 confirmSignatureRequest: async () => {548 const notificationPage = await playwright.switchToMetamaskNotification();549 playwright.waitAndClick(550 signaturePageElements.confirmSignatureRequestButton,551 notificationPage,552 { waitForEvent: 'close' },553 );554 return true;555 },556 confirmDataSignatureRequest: async () => {557 const notificationPage = await playwright.switchToMetamaskNotification();558 await playwright.waitAndClick(559 dataSignaturePageElements.confirmDataSignatureRequestButton,560 notificationPage,561 { waitForEvent: 'close' },562 );563 return true;564 },565 rejectSignatureRequest: async () => {566 const notificationPage = await playwright.switchToMetamaskNotification();567 await playwright.waitAndClick(568 signaturePageElements.rejectSignatureRequestButton,569 notificationPage,570 { waitForEvent: 'close' },571 );572 return true;573 },574 rejectDataSignatureRequest: async () => {575 const notificationPage = await playwright.switchToMetamaskNotification();576 await playwright.waitAndClick(577 dataSignaturePageElements.rejectDataSignatureRequestButton,578 notificationPage,579 { waitForEvent: 'close' },580 );581 return true;582 },583 confirmPermissionToSpend: async () => {584 const notificationPage = await playwright.switchToMetamaskNotification();585 await playwright.waitAndClick(586 notificationPageElements.allowToSpendButton,587 notificationPage,588 { waitForEvent: 'close' },589 );590 return true;591 },592 rejectPermissionToSpend: async () => {593 const notificationPage = await playwright.switchToMetamaskNotification();594 await playwright.waitAndClick(595 notificationPageElements.rejectToSpendButton,596 notificationPage,597 { waitForEvent: 'close' },598 );599 return true;600 },601 acceptAccess: async allAccounts => {602 const notificationPage = await playwright.switchToMetamaskNotification();603 // todo: allAccounts doesn't work? - waitAndClick has .first()604 if (allAccounts === true) {605 await playwright.waitAndClick(606 notificationPageElements.selectAllCheck,607 notificationPage,608 );609 }610 await playwright.waitAndClick(611 notificationPageElements.nextButton,612 notificationPage,613 { waitForEvent: 'navi' },614 );615 await playwright.waitAndClick(616 permissionsPageElements.connectButton,617 notificationPage,618 { waitForEvent: 'close' },619 );620 return true;621 },622 confirmTransaction: async gasConfig => {623 const notificationPage = await playwright.switchToMetamaskNotification();624 if (gasConfig && gasConfig.gasFee) {625 await playwright.waitAndSetValue(626 gasConfig.gasFee.toString(),627 confirmPageElements.gasFeeInput,628 notificationPage,629 );630 } else if (getNetwork().isTestnet) {631 await playwright.waitAndClick(632 confirmPageElements.gasFeeArrowUpButton,633 notificationPage,634 1,635 );636 } else {637 await playwright.waitAndClick(638 confirmPageElements.gasFeeArrowUpButton,639 notificationPage,640 10,641 );642 }643 if (gasConfig && gasConfig.gasLimit) {644 await playwright.waitAndSetValue(645 gasConfig.gasLimit.toString(),646 confirmPageElements.gasLimitInput,647 notificationPage,648 );649 }650 const gasLimitInput = confirmPageElements.gasLimitInput;651 await notificationPage.waitForFunction(652 gasLimitInput => document.querySelector(gasLimitInput).value != '0',653 gasLimitInput,654 );655 await playwright.waitAndClick(656 confirmPageElements.confirmButton,657 notificationPage,658 { waitForEvent: 'close' },659 );660 return true;661 },662 rejectTransaction: async () => {663 const notificationPage = await playwright.switchToMetamaskNotification();664 await playwright.waitAndClick(665 confirmPageElements.rejectButton,666 notificationPage,667 { waitForEvent: 'close' },668 );669 return true;670 },671 confirmEncryptionPublicKeyRequest: async () => {672 const notificationPage = await playwright.switchToMetamaskNotification();673 await playwright.waitAndClick(674 encryptionPublicKeyPageElements.confirmEncryptionPublicKeyButton,675 notificationPage,676 { waitForEvent: 'close' },677 );678 return true;679 },680 rejectEncryptionPublicKeyRequest: async () => {681 const notificationPage = await playwright.switchToMetamaskNotification();682 await playwright.waitAndClick(683 encryptionPublicKeyPageElements.rejectEncryptionPublicKeyButton,684 notificationPage,685 { waitForEvent: 'close' },686 );687 return true;688 },689 confirmDecryptionRequest: async () => {690 const notificationPage = await playwright.switchToMetamaskNotification();691 await playwright.waitAndClick(692 decryptPageElements.confirmDecryptionRequestButton,693 notificationPage,694 { waitForEvent: 'close' },695 );696 return true;697 },698 rejectDecryptionRequest: async () => {699 const notificationPage = await playwright.switchToMetamaskNotification();700 await playwright.waitAndClick(701 decryptPageElements.rejectDecryptionRequestButton,702 notificationPage,703 { waitForEvent: 'close' },704 );705 return true;706 },707 allowToAddNetwork: async ({ waitForEvent } = {}) => {708 const notificationPage = await playwright.switchToMetamaskNotification();709 if (waitForEvent) {710 await playwright.waitAndClick(711 confirmationPageElements.footer.approveButton,712 notificationPage,713 { waitForEvent },714 );715 } else {716 await playwright.waitAndClick(717 confirmationPageElements.footer.approveButton,718 notificationPage,719 );720 }721 return true;722 },723 rejectToAddNetwork: async () => {724 const notificationPage = await playwright.switchToMetamaskNotification();725 await playwright.waitAndClick(726 confirmationPageElements.footer.cancelButton,727 notificationPage,728 { waitForEvent: 'close' },729 );730 return true;731 },732 allowToSwitchNetwork: async () => {733 const notificationPage = await playwright.switchToMetamaskNotification();734 await playwright.waitAndClick(735 confirmationPageElements.footer.approveButton,736 notificationPage,737 { waitForEvent: 'close' },738 );739 return true;740 },741 rejectToSwitchNetwork: async () => {742 const notificationPage = await playwright.switchToMetamaskNotification();743 await playwright.waitAndClick(744 confirmationPageElements.footer.cancelButton,745 notificationPage,746 { waitForEvent: 'close' },747 );748 return true;749 },750 allowToAddAndSwitchNetwork: async () => {751 await module.exports.allowToAddNetwork();752 await module.exports.allowToSwitchNetwork();753 return true;754 },755 getWalletAddress: async () => {756 await switchToMetamaskIfNotActive();757 await playwright.waitAndClick(mainPageElements.optionsMenu.button);758 await playwright.waitAndClick(759 mainPageElements.optionsMenu.accountDetailsButton,760 );761 walletAddress = await playwright.waitAndGetValue(762 mainPageElements.accountModal.walletAddressInput,763 );764 await playwright.waitAndClick(mainPageElements.accountModal.closeButton);765 await switchToCypressIfNotActive();766 return walletAddress;767 },768 initialSetup: async ({ secretWordsOrPrivateKey, network, password }) => {769 const isCustomNetwork =770 (process.env.NETWORK_NAME &&771 process.env.RPC_URL &&772 process.env.CHAIN_ID) ||773 typeof network == 'object';774 await playwright.init();775 await playwright.assignWindows();776 await playwright.assignActiveTabName('metamask');777 await module.exports.getExtensionDetails();778 await module.exports.fixBlankPage();779 if (780 (await playwright781 .metamaskWindow()782 .$(welcomePageElements.confirmButton)) !== null783 ) {784 await module.exports.confirmWelcomePage();785 if (secretWordsOrPrivateKey.includes(' ')) {786 // secret words787 await module.exports.importWallet(secretWordsOrPrivateKey, password);788 } else {789 // private key790 await module.exports.createWallet(password);791 await module.exports.importAccount(secretWordsOrPrivateKey);792 }793 if (isCustomNetwork) {794 await module.exports.addNetwork(network);795 } else {796 await module.exports.changeNetwork(network);797 }798 walletAddress = await module.exports.getWalletAddress();799 await playwright.switchToCypressWindow();800 return true;801 } else if (802 (await playwright803 .metamaskWindow()804 .$(unlockPageElements.passwordInput)) !== null805 ) {806 await module.exports.unlock(password);807 walletAddress = await module.exports.getWalletAddress();808 await playwright.switchToCypressWindow();809 return true;810 } else {811 if (812 (await playwright813 .metamaskWindow()814 .$(mainPageElements.walletOverview)) !== null &&815 !process.env.RESET_METAMASK816 ) {817 await playwright.switchToMetamaskWindow();818 walletAddress = await module.exports.getWalletAddress();819 await playwright.switchToCypressWindow();820 return true;821 } else {822 // todo: reset metamask state823 }824 }825 },826};827async function switchToMetamaskIfNotActive() {828 if (await playwright.isCypressWindowActive()) {829 await playwright.switchToMetamaskWindow();830 switchBackToCypressWindow = true;831 }832 return switchBackToCypressWindow;833}834async function switchToCypressIfNotActive() {835 if (switchBackToCypressWindow) {836 await playwright.switchToCypressWindow();837 switchBackToCypressWindow = false;838 }839 return switchBackToCypressWindow;...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...145 const rejected = await metamask.rejectSignatureRequest();146 return rejected;147 },148 rejectMetamaskDataSignatureRequest: async () => {149 const rejected = await metamask.rejectDataSignatureRequest();150 return rejected;151 },152 confirmMetamaskEncryptionPublicKeyRequest: async () => {153 const confirmed = await metamask.confirmEncryptionPublicKeyRequest();154 return confirmed;155 },156 rejectMetamaskEncryptionPublicKeyRequest: async () => {157 const rejected = await metamask.rejectEncryptionPublicKeyRequest();158 return rejected;159 },160 confirmMetamaskDecryptionRequest: async () => {161 const confirmed = await metamask.confirmDecryptionRequest();162 return confirmed;163 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Synpress } = require('synthetixio-synpress');2const { SynthetixJs } = require('synthetix-js');3const synpress = new Synpress();4const synthetixJs = new SynthetixJs();5const { privateKey, address, networkId } = synpress.getAccounts()[0];6const synthetix = synthetixJs.contractSettingsForNetwork(networkId);7const data = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const synthetixioSynpress = require('synthetixio-synpress');2const synthetixioSynpressInstance = new synthetixioSynpress();3const rejectDataSignatureRequest = synthetixioSynpressInstance.rejectDataSignatureRequest;4const address = '0x8a9f9c5f5b5a5b5a5a5a5a5a5a5a5a5a5a5a5a5a';5const requestID = 123;6const rejectDataSignatureRequestResult = rejectDataSignatureRequest(address, requestID);7console.log(rejectDataSignatureRequestResult);8const synthetixioSynpress = require('synthetixio-synpress');9const synthetixioSynpressInstance = new synthetixioSynpress();10const isDataSignatureRequestValid = synthetixioSynpressInstance.isDataSignatureRequestValid;11const address = '0x8a9f9c5f5b5a5b5a5a5a5a5a5a5a5a5a5a5a5a5a';12const requestID = 123;13const isDataSignatureRequestValidResult = isDataSignatureRequestValid(address, requestID);14console.log(isDataSignatureRequestValidResult);15const synthetixioSynpress = require('synthetixio-synpress');16const synthetixioSynpressInstance = new synthetixioSynpress();17const isDataSignatureRequestRejected = synthetixioSynpressInstance.isDataSignatureRequestRejected;

Full Screen

Using AI Code Generation

copy

Full Screen

1var synthetixio = require('synthetixio-synpress');2var synthetix = new synthetixio();3var Synpress = require('synpress');4Synpress.init({5});6Synpress.run({7 browserOptions: {8 },9 mochaOpts: {10 }11});12const { expect } = require('chai');13const Synpress = require('synpress');14const synthetix = require('synthetixio-synpress');15const Synthetix = new synthetix();16const { assert } = require('chai');17describe('Synthetix Test', () => {18 before(async () => {19 await Synpress.openBrowser();20 });21 after(async () => {22 await Synpress.closeBrowser();23 });24 it('Reject Data Signature Request', async () => {25 await Synpress.openUrl('/');26 await Synpress.clickOn(Synthetix.loginButton);27 await Synpress.clickOn(Synthetix.metamaskButton);28 await Synpress.clickOn(Synthetix.rejectDataSignatureRequest);29 });30});31const Synpress = require('synpress');32module.exports = {33 loginButton: Synpress.element({ selector: 'button[data-testid="login-button"]' }),34 metamaskButton: Synpress.element({ selector: 'button[data-testid="metamask-button"]' }),35 rejectDataSignatureRequest: Synpress.element({ selector: 'button[data-testid="reject-data-signature-request"]' })36};

Full Screen

Using AI Code Generation

copy

Full Screen

1(async () => {2 const synthetixioSynpress = require('synthetixio-synpress');3 const snx = new synthetixioSynpress();4 const address = "0x8d3f0c3b7f7d1b2f2b0a1c594e4e9c4f4f7b4e4f";5 const transactionHash = "0x8d3f0c3b7f7d1b2f2b0a1c594e4e9c4f4f7b4e4f";6 const rejectDataSignatureRequest = await snx.rejectDataSignatureRequest(address, transactionHash);7 console.log(rejectDataSignatureRequest);8})();9const synthetixioSynpress = require('synthetixio-synpress');10const snx = new synthetixioSynpress();11const address = "0x8d3f0c3b7f7d1b2f2b0a1c594e4e9c4f4f7b4e4f";12const transactionHash = "0x8d3f0c3b7f7d1b2f2b0a1c594e4e9c4f4f7b4e4f";13snx.rejectDataSignatureRequest(address, transactionHash)14 .then(rejectDataSignatureRequest => {15 console.log(rejectDataSignatureRequest);16 })17 .catch(error => {18 console.log(error);19 });20const synthetixioSynpress = require('synthetixio-synpress');21const snx = new synthetixioSynpress();22const address = "0x8d3f0c3b7f7d1b2f2b0a1c594e4e9c4f4f7b4e4f";

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run synthetixio-synpress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful