Implement Synpress support methods in your Web3 tests

Hello guys,

Today I am going to post a quick and easy to use snippet with Synpress MetaMask support methods in your Web3 E2E (end-to-end) Test Project.

Create a base class to get the Synpress methods and extend it to use across the project. Here are some examples of methods that you can have:

export default class MetaMaskSupport {
  getCurrentNetwork() {
    return cy.getNetwork();
  }

 isMetamaskWindowActive() {
      return cy.isMetamaskWindowActive();
  }

  getMetamaskWalletAddress() {
    return cy.fetchMetamaskWalletAddress();
  }

  acceptMetamaskAccessRequest() {
    cy.acceptMetamaskAccess();
  }
}

Then you can either extend the class:

import MetaMaskSupport from '../metaMaskSupport';

export default class HomePage extends MetaMaskSupport {
  constructor() {
    super();
  }

  visit() {
    cy.visit('/');
  }

  waitUntilLoggedIn() {
    cy.waitUntil(() => {
      const walletAddress = this.getMetamaskWalletAddress();
      return walletAddress.should('exist');
    });
  }

  getLoggedInWalletAddress() {
    const walletAddress = this.getMetamaskWalletAddress();
    return walletAddress.invoke('text');
  }
}

Or you can instantiate as an object:

import MetaMaskSupport from '../metaMaskSupport';

export default class HomePage {
  constructor() {
    super();
    this.metaMaskSupport = new MetaMaskSupport();
  }

  visit() {
    cy.visit('/');
  }

  waitUntilLoggedIn() {
    cy.waitUntil(() => {
      const walletAddress = this.metaMaskSupport.getMetamaskWalletAddress();
      return walletAddress.should('exist');
    });
  }

  getLoggedInWalletAddress() {
    const walletAddress = this.metaMaskSupport.getMetamaskWalletAddress();
    return walletAddress.invoke('text');
  }
}

Now, get yourself a drink, you deserve it 🤣

2022 – End of the year learnings

Finally this year is over ! I have done a lot of things, mostly of them were solving problems that arose all of the sudden, but I’m mostly grateful for everything that I have been through, even the shit shows that happened. You know what people say, good times are great, but bad times help you to build character.

I finally was able to go to San Francisco Bay Area for an entrepreneurship course at Draper University that I’ve signed up for before the pandemic to focus on my new/old goal.

It has been a tornado of things to learn/refresh my mind, but here are some things that I took from this first week:

  • Never travel with tight connections. But when you do attach an airtag to your luggage! And in case your luggage gets lost, buy second hand or clothes that you can return.
    • Aer Lingus lost my bag during a connection in Dublin to San Francisco, it was 3 weeks without my clothes, not a really nice experience.
  • Everybody is in a different stage and journey in life, don’t feel demotivated by others. NO MATTER WHAT.
  • Keep learning (This is my every day reminder)
  • Make real connections with genuine good-quality people and life becomes more joyful even when things are difficult. Also, it is way easier to learn from people like this.
  • Observe and listen more than speak. (Every day reminder as well, but I am more a listener than a talker since I can remember)
  • Travelling by yourself is amazing (not new, but for all the people out there that are afraid to try, GO FOR IT)
  • Build your network independently if they are only virtual connections (for now) or not.
    • C’mon we have enough tools nowadays to allow us to drink some wine together with a friend on the other side of the world.
  • If you are at the beginning of your journey, look for mentorship and advice. Knowledge saves loads of time.
    • But be careful and look for real mentors, there are plenty of frauds around there.I can keep a healthy mindset in my old age to listen to others no matter their level. ❤️
  • Be a rebel ! (Another reminder, sorry mom haha)
  • Don’t wait too long and just do it, but also enjoy the journey.
  • Flying cars are real and they are available for sale already.
  • Don’t trust on those water-resisting plastic bags for your mobile ! The water is going to come inside even if you are in the shallow part !!
  • Have a dash cam on your car !
  • Have backups when you travel ! A backup phone and maybe even a paper with important phone numbers on your wallet (Don’t trust in tech that much)
  • Stay far from negative and prepotent people, but not too far. I believe they help you to build emotional intelligence, you have the power to decide if what they say is going to be the fuel for you to progress or if you are going to allow them to drag you down. Transform the judgemental comments into constructive feedback and ignore the rest.

And last just sharing my 360 review result, for all the people that have helped me with this, my big thanks. Looks like all this time interested in communication styles and human behaviour made me a more self aware person and I am not an asshole after all 😂

Using openAI to create content for social media

Hello Hello 👋👋👋

Today my post is a bit different from the others as I was having some fun with AI last weekend. I realised I was spending too much time thinking about the content, adding some fun emojis and adding the hashtags for posts on social media.

Then I spent last Saturday evening creating this tool with OpenAI 🤖 quite basic now, but I am planning to have small increments as we go.

It's been a fun couple of hours doing research, coding, and testing, but it's here!  This AI tool can increase efficiency and optimize the content creation. 💪    

This paragraph was generated with the tool

If you are curious about the code and you want to run locally, this is the repo:

https://github.com/rafaelaazevedo/rediskets

You will need to create a .env file and add your OpenAI API Key, which is generated on their website after you create your account there (It is FREE).

If you just want to try it out, open the link and add the text explaining what your content should be about, maybe even add some personality like (friendly, assertive, etc) to help AI to find out what is more close to what you want. It will generate a post with emojis, hashtags and a picture related to what you wrote. The picture is definitely not the brightest feature as you saw above, but maybe you will have some fun like me and generate a picture of dogs without faces 😂

PS: you might get some 502 errors (they are random and unfortunately is because I am using a free trial and OpenAI api is returning the query with some timeouts) 😔

https://rediskets.netlify.app/

This really represents me after I deployed my code !

E2E Tests for Web3 Applications (TestJS Summit 2022)

It is out 🎉🎉

If you are curious to know about web3 and how can you test it, here are some ideas!

We will go through a brief explanation of what is Web3 and the architecture of a web3 application. Then we will talk about how to do end-to-end tests, its challenges, some test tools that are available, and 2 demos using Synpress and mocking the web3 layer.

The agenda is:

– What is Web3;

– The Architecture of a Web3 Application;

– Web3 E2E Tests Introduction;

– Web3 E2E Tests Challenges;

– E2E Test Tools;

Demo.

https://portal.gitnation.org/contents/e2e-tests-for-web3-applications

It took me ages to record this video, not going to deny, I am still improving my video editor/design skills… I even bought a new mic to help me and would love to have some feedback about the talk in general.

If you have literally 5 seconds, here is the link.

The big news is, we have created a Web3 Tests Community on Discord !

Yes, me and Jakub, one of the creators of Synpress, are on that and we are looking for contributors and members (of course) 🙂

  1. Yes, I know… We have too many places to create a community nowadays 😩, but this one is going to be one for all of our Web3 Testing people.
  2. Still in the beginning so bear with us while we build and share the content.
  3. Join and share 🤩

Monitoring and Alert Test Strategy Meetup

Hello all, in July I presented this meetup about Monitoring and Alerts Test Strategy for the Test Automation Talks Group.

Here are the slides:

The demos with different from the slides:

AWS Fault Injection Simulator

Chaos Engineering with Gremlin

ChaosMesh Doc

https://chaos-mesh.org/docs/basic-features/

KubeMonkey – Running Chaos Engineering

As always if you have any questions or feedback just ping me a message 😀

Dependency Injection with Selenium and Spring Boot

Hello guys,

Today I am going to share something that I learned recently. I am aware that so many people probably have been using this a long time ago, but I have moved away from java and Selenium quite some time ago and I recently got back into it.

So here is a boilerplate with an automated test project using Dependency Injection of Spring Boot with Selenium, Gradle, and Cucumber.

Feel free to contribute or give any feedback !!

Github project: https://github.com/rafaelaazevedo/Scrux

Benefits of AI in Test Automation

Photo by Kindel Media on Pexels.com

There are several interesting web app automation scenarios that we can improve using AI:

  • Reduce the execution time: Nowadays you have the feature target function already even without an AI test automation project, but with AI you can add this feature without having cucumber in place or even the need to tag the scenarios or features. The AI should be able to identify the features related to the change automatically.
  • Converted manual test cases to automation: you can use Natural Language Processing (NLP) to automatically translate manual test cases into automated test cases. I have seen this done with cucumber not AI yet, but totally possible as AI models work on datasets.
  • Creating different data combinations by training the AI to identify the possible combinations based on a dataset is possible. This would increase the data coverage and bring more confidence to the automation project.
  • Visual validations: Many tools perform this functionality already. I personally tried one tool ages ago called Percy, but you can also try some other popular tools like Applitools and Telerik
  • Test execution stability or self-healing automation: AI can automatically locate web elements when the primary locators fail. You can see this feature in some cutting-edge automation tools like Mabl and Xray and Functionize. Self-healing employs data analytics to identify objects in a script even after they have changed. When your script fails due to being unable to find the object it expected, the self-healing mechanism provides a fuller understanding and analysis of options. Rather than shutting down the process, it examines objects holistically, evaluates the attributes and properties of all available objects, and uses a weighted scoring system to select the one most similar to the one previously used.

Becoming a Domain Model Expert

Creating a model for your test automation requires a domain expert, therefore is critical to have a test automation specialist that also knows the business so the AI can bring the desired innovation. With such extensive use cases, AI systems will need different parameters from domain experts.

Machine Learning Algorithms In Layman's Terms, Part 1 | by Audrey  Lorberfeld | Towards Data Science
https://wordstream-files-prod.s3.amazonaws.com/s3fs-public/machine-learning.png

Be careful to not run more automated tests than you actually need it. A stage of supervision when the AI is learning the patterns is definitely needed it.

Resources:

Breaking The Bias – International Women’s Day

Hello guys,

As part of my STEM Ambassadors activity to bring more young women to the STEM area, I recorded a video telling my career history and how I ended up in tech.

As you know women are still a minority and one of the reasons why is that some people still believe there is a rule saying tech is a man’s job or a woman’s job. This is me when I hear these comments:

I wish the world was binary and simple like that.

Here is the presentation in case you are curious about how I ended up where I am now 😊

Javascript Executor with PageFactory Selenium

Photo by Antonio Batiniu0107 on Pexels.com

Hello guys,

Today I am going to post another problem that cost me a lot of research time and pulling out my own hair.

This was the initial code:

    public void javascriptExecutor(String script, WebElement element) {
       WebDriver driver = new ChromeDriver();  
       JavascriptExecutor jse = (JavascriptExecutor) driver;  
       jse.executeScript(script, element);  
    }

If you ever encounter the error complaining Selenium couldn’t find the Webdriver instance, then check the complete explanation of the problem here.

TL;DR; Webdriver when using PageFactory needs to extract the underlying WebElement with WrapsElement and then the WebDriver from it. Basically, you need to get the real element and then you will be able to use javascript executor:

    public void javascriptExecutor(String script, WebElement element) {  
       WebDriver driver = ((WrapsDriver)((WrapsElement)element).getWrappedElement()).getWrappedDriver();
       JavascriptExecutor jse = (JavascriptExecutor) driver;  
       jse.executeScript(script, element);  
    }

So, next time this problem comes up it will be smooth to fix and not days of trying to figure out what is happening 😂

Stale Element when using PageFactory – Selenium

Photo by luis gomes on Pexels.com

Hello guys,

The first post of the year will be a quick one. Took me a while to figure out since it has been ages I coded in Selenium/Java and used PageFactory (which I thought was deprecated, but it is just deprecated in C#)

If you ever come across an error like this when using PageFactory:

stale element reference: element is not attached to the page document

PageFactory initializes the elements the first time you run the automation and when the page changes (which happens on Angular and React pages) Selenium loses the reference to that element and needs to find it again with the new DOM.

You can do something like this:

protected void clickElement(WebElement element) {
   try {
      webDriverUtils.waitForElementToBePresent(element);
      element.click();
   } catch (StaleElementReferenceException e) {
       PageFactory.initElements(driver, this);
   }