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.getWalletAddress();
      return walletAddress.should('exist');
    });
  }

  getLoggedInWalletAddress() {
    const walletAddress = this.getWalletAddress();
    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.getWalletAddress();
      return walletAddress.should('exist');
    });
  }

  getLoggedInWalletAddress() {
    const walletAddress = this.metaMaskSupport.getWalletAddress();
    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

Monitoring & Alert Test Strategy

Having an alert system is crucial to have confidence in your product. There are 2 main points you need to consider, Monitoring and Alerts:

  • Monitoring consists of dashboards and reports to display the metrics.
  • Alerts involve taking some type of action such as notifying someone, writing to a log, and raising an alert on a dashboard.

Having an alert system is crucial to delivering the right information to the right people at the right time

Important Metrics to Watch

The list is long and you can get lost on all the possible metrics you can watch and raise an alert upon. A good strategy is starting with the riskiest ones, the ones that can stop the system to work, stability, and performance. Here is a list of some of the most-watched metrics:

CPU utilization 
Memory utilization
Memory breakup
Load balancer (Number of instances running)
Services and processes running
Processor queue length  
Disk usage
Network up 
Plugin
Crontab executed
Event logs generated
Application details
Expiring Certificates
Docker/Kubernetes containers

These metrics can be swapped or removed or you can even add others according to your needs. The goal here is to find the best metrics to watch and raise different levels of alerts to the specific group of people at the right time. These metrics can help the team to check the system’s health and also increase the confidence and reliability not only in the recovery steps when something goes sideways but also in the alert system itself.

Different Types of Metrics

I found this good framework to create a good alert. It needs to have these properties:

Actionable: Indicates a problem for which the recipient is well placed to take immediate action.
Investigable: Indicates a problem whose solution is not yet known by the organization.

Do you need to take an action every time? No, you can specify a capacity limit, and then once the metric reaches this limit you can have the first support acting up on it, then when it reaches the second limit then you have a different action like calling the second line support, or calling a script to restart a service, etc.

Sometimes there is no action to take. For example, โ€œCPU utilizationโ€ or โ€œPacket loss.โ€ These are some classic FYI alerts. Instead of alerting, these things should appear on a dashboard for use in troubleshooting when a problem is already known to exist.

Do you need to send the alert straight away? Also no, especially when you have mechanisms of self-healing. Thereโ€™s no need to bother a human to fix the issue; the response should be automated.

Depending on your recovery strategy, you can wait 5, 10, or 15 minutes to check if the metric is still showing a problem, and then, if it is you can raise the alert accordingly. In the alert, you can always have a link to the documentation with recovery steps (e.g. a โ€œrunbookโ€ indicating steps to perform).

Remember to have an FYI for when the problem is fixed as well, so in case something has failed in the middle of the evening and in the morning is working, you get the latest update about the problem.

Always keep records and logs to investigate what happened and how the system reacted.

Dan Slimmon has a good spreadsheet example of an alert framework:

Monitoring and Alert Tests

Independently the tool you are using for your metrics and alerts: Grafana, Cloudwatch, Sensu, Prometheus, or New Relic. It is important to have a test strategy to cover this critical part of your system.

Some common tests you need to perform are much more Devops related, like scaling down some instances on AWS, simulating a high memory load with scripts, or even creating scripts specific to remove log files from the Docker container.

Points to keep in mind:

Is it worth automating?

Think about if you have a lot of changes and maintenance to the project. How much effort would be to create the automation for these scenarios? How complex these scenarios would be? Does automating them bring any real value?

There are some tools that you can use to perform chaos engineering:

AWS FIS (Fault injection Actions Simulator) to automate some of the scenarios and add to your continuous delivery pipeline. It’s a fully managed service for running fault injection experiments on AWS that makes it easier to improve an applicationโ€™s performance, observability, and resiliency.

Chaos Mesh utilizes chaos experiments within Kubernetes environments. Itโ€™s able to use various types of scenarios related to fault simulations within a distributed system.

Many other tools can be used and you can check the list in this post.

At what stages do you want to test and what scope?

Check if you need to do manual smoke tests for each feature and then have a bigger regression after merging the tickets, or manual test for the feature and at the same time add the automation for this scenario, so at the end of the pipeline, you have the full regression.


Maybe you don’t even need to have automation running for this project and just doing manual feature tests for the tickets and having a report with the full regression scenarios is enough

Whatever is the strategy that you choose, make sure you have the max confidence you can have with the current constraints and a plan to improve in the near future.

Automating these tests is complex and always involves a good knowledge of infrastructure. I personally had and still have to do a lot of research when it comes to it.

Resources

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 ๐Ÿ˜‚