Cypress MetaMask Connection Automation Issue #26853
Unanswered
ejaz-hussain-1050
asked this question in
Questions and Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem:
We are developing a Web3 project using ReactJS for the frontend. The project involves connecting wallets and handling the Metamask extension. For this purpose, we are utilizing two Web3 libraries in ReactJS:
@web3modal/ethereum (version 2.2.1)
@web3modal/react (version 2.2.1)
However, we are facing difficulties while automating the wallet connection in Cypress. Specifically, when we click on the Web3 button through automation, the behavior is inconsistent. In most cases, the modal fails to open, and the text of the Web3 button changes to "connecting." Additionally, an error is thrown stating "Error: No valid element provided." Although there are instances when the automation works correctly, we have been unable to pinpoint the root cause of this issue.
Code:
cy.on('uncaught:exception', (err) => {
console.error('Unhandled Promise Rejection:', err);
return false;
});
cy.get('[class=" "]', { includeShadowDom: true }).click();
cy.wait(2000);
cy.get('w3m-wallet-button', {
includeShadowDom: true,
}).first().click();
Expected Behavior:
Upon clicking the Web3 button, the modal should consistently open, facilitating the wallet connection process.
Actual Behavior:
The modal fails to open consistently, and the text of the Web3 button changes to "connecting" without establishing the connection. As a result, the automation does not behave as expected, and the "Error: No valid element provided" exception is encountered more frequently than the desired behavior.
Additional Notes:
We have chosen ReactJS as our frontend framework and are utilizing the following Web3 libraries for wallet connection and Metamask handling:
@web3modal/ethereum (version 2.2.1)
@web3modal/react (version 2.2.1)
Despite attempting cache clearance and employing various debugging techniques, we have been unable to resolve the issue. Consequently, we are seeking assistance in identifying the cause and rectifying the inconsistent behavior of the wallet connection automation in Cypress.
Beta Was this translation helpful? Give feedback.
All reactions