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 😂

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);
   }

Blockchain Tests Workshop at The National Software Testing Conference

Hello guys, here are the slides from the workshop on Blockchain Tests that I gave earlier this week, as well as some responses to the issues that were addressed during the session. I can say as my first presential workshop after pandemic, it was a great experience with a full room 😃


Unfortunately, there is no recording of it, but you may clone the repo and follow the coding instructions to build the test class and methods, then compare to version 2 of the project, which has the most recent version.

What is the Required() function in Solidity?

The require Solidity function guarantees validity of conditions that cannot be detected before execution. It checks inputs, contract state variables and return values from calls to external contracts.

Where the Address type comes from ?

The address type comes in two flavours, which are largely identical:

  • address: Holds a 20 byte value (size of an Ethereum address).
  • address payable: Same as address, but with the additional members transfer and send.

The idea behind this distinction is that address payable is an address you can send Ether to, while a plain address cannot be sent Ether.

Type conversions

Implicit conversions from address payable to address are allowed, whereas conversions from address to address payable must be explicit via payable(<address>).

Explicit conversions to and from address are allowed for uint160, integer literals, bytes20 and contract types.

Other tools that you can use to test Blockchain applications

  • Ethereum Tester,
  • Hyperledger Composer
  • Exonum test kit
  • Embark
  • Populus
  • BitcoinJ
  • Binance

Resources