Portfolio

Marcelo Costa

Unsplashed background img 1


Amazon Automation

Using Cypress

cypress-logo
amazon-website

I have recently created a compact and efficient test suite using the Cypress testing framework. The suite runs through the Amazon website and verifies the contents of the shopping cart in various ways. The test suite was written using JavaScript, a high-level programming language that is widely used for web development.

In order to run the test suite, you will need to have Cypress installed, as well as Node.js and NPM. A web browser will also be required. If you would like more information on how to set up and run the test suite, please follow the link provided, where I have detailed all the necessary steps.

javascript-logo

The test suite contains three distinct test cases:

1. Verify Amazon's Title Webpage.

2. Search For a Nespresso Coffee Machine And Assert It In The Cart.

3. Search For A Specific Nespresso Machine And Assert It In The Cart In A Different Way.



Video of the Test Suite

Runs and asserts in 51 seconds:







Code Explained:


        
          describe('Amazon', function() {
            beforeEach(function() {
             //Visits the Amazon Spain webpage:
             cy.visit('https://www.amazon.es/')
             //Clicks on the continue without accepting cookies for better visualization of the exercise:
             cy.get('#sp-cc-rejectall-container').click()
           })
           it('Verifies the title of the Webpage', function() {
             cy.title().should('be.equal', 'Amazon.es: compra online de electrónica, libros, deporte, hogar, moda y mucho más.') //Assertion of the Amazon webpage by its title, not the h1, the 
         })
           it('Searches for a Nespresso product and adds it to the cart', function() {

             cy.get('#twotabsearchtextbox').type('Cafetera Nespresso') //Here, it finds the search bar and clicks on it and writes 'Cafetera Nespresso'
             cy.get('#nav-search-submit-button').click() //It looks for the search icon and clicks on it
             cy.get('[data-asin="B00G5YOVZA"] > .sg-col-inner > .s-widget-container > .s-card-container > .a-spacing-base > .s-product-image-container > .rush-component > .a-link-normal > .a-section > .s-image').scrollIntoView().click() //Here I'm telling Cypress to look for a specific coffee machine by its ID, and it scrolls down until it finds and then clicks on it
             cy.get('#add-to-cart-button-ubb').click() //It looks for the 'Add to cart' button and clicks on it
             cy.get('#sw-gtc > .a-button-inner > .a-button-text').click() //It looks for the 'View this in cart' button and clicks on it
             //Assertion
             cy.get('h1').contains('Cesta') //And finally the assertion, when we enter the 'Cart' page, there's an element called 'Cesta' in the page, which it looks for it by it's ID and it verifies that it contains the text 'Cesta' and it assures that it passes.
           })
           //Here, I want to do the same test case in a different way
           it('Searches for a specific Nespresso SNE900 product, adds it to the cart and validates it', function() {

             cy.get('#twotabsearchtextbox').type('NESPRESSO SNE900') //Here, it finds the search bar and clicks on it and writes 'NESPRESSO SNE900'
             cy.get('#nav-search-submit-button').click() //It looks for the search icon and clicks on it
             cy.get('[data-asin="B08LDSF6XP"] > .sg-col-inner > .s-widget-container > .s-card-container > :nth-child(1) > .puis-padding-left-small > .s-title-instructions-style > .a-size-mini > .a-link-normal > .a-size-base-plus').click() //Since there's 23 results, I tell cypress to click on the model of the coffee machine by the ID that I've passed on
             cy.get('#add-to-cart-button').click() //It looks for the 'Add to cart' button and clicks on it
             cy.get('#attachSiNoCoverage').click() //It looks for the 'No, thank you' in the Extra Warranty slider and clicks on it
             cy.get('#sw-gtc > .a-button-inner > .a-button-text').click() //It looks for the 'View this in cart' button and clicks on it
             //Assertion
             cy.get('.a-color-base > .a-truncate > .a-truncate-cut').contains('NESPRESSO SNE900') //Here the assertion is slightly different than in the last test case, it looks 'NESPRESSO SNE900' is in the child element inside the cart. It finds it and it passes the test.
           })

           })
           
          




Cucumber and Appium

Unsplashed background img 2


Android Automation

Using Cucumber, Appium and Ruby

cucumber-logo
amazon-website

This is a test made for Android using Android Studio for a simulated device in which I used a real life app called "Unit Converter", available here. I've created a total of 14 test cases in which they're really simple to read and test the Main menu of the app, the Home screen and the Gestures. To develop this test I used Cucumber test engine with Gherkin language, executing through Ruby environment, with Appium driver in a simulated Android device.

cypress-logo

I've installed the app inside an Android simulated device, using "adb install" command in terminal. Then, I created the feature file of each section I wanted to test, in which I detailed the steps of execution through Ruby language. I also created tags, hooks, detailed the environment in Ruby, which you can see it in my GitHub link down below.

Here are some of the test cases I've written:

ruby-logo

Show all button should be enabled at launch;

When I tap on menu icon, I should see left side menu;

User able to select values from unit pickers;

User able to swipe to open Calculator.



Video of the Test Suite

Runs and asserts 14 screnarios in 4 minutes:







Gherkin code:


            
              @home_screen
              Feature: Tests for Home Screen Functionality
              
                Background:
                  Given I land on home screen
              
                @default
                Scenario: Default values on home screen is Foot and Centimeter
                  Then  Left Unit picker value should be "Foot"
                  And Right unit picker value should be "Centimeter"
              
                Scenario: Show all button should be enabled at launch
                  Then Show All button should be disabled
                  When I type "1" on application keyboard
                  Then Show All button should be enabled
              
              
                Scenario Outline: Verify default conversion
                  When I type "" on application keyboard
                  Then I should see results as ""
              
              Examples:
                  |target|result   |
                  |1     |30.48    |
                  |2     |60.96    |
                  |3     |91.44    |
                  |9     |274.32   |
                  |1011  |30 815.28|
              
              
                Scenario: User able to add current conversion to Favorites list
                  Then I press on Add to Favorites icon
                  When I press on menu icon
                  Then I press on Favorite conversions
                  And I verify "Length" added to Favorite conversions list
              
                Scenario: User able to search by existing Conversion type
                  Then I press on search icon
                  Then I type "Temperature" in search field
                  And I press return button on soft keyboard
                  Then I see "Temperature" as a current unit converter
                  Then Left Unit picker value should be "Celsius"
                  And Right unit picker value should be "Fahrenheit"
              
                Scenario Outline: User able to select values from unit pickers
                  Then I select "" from left unit picker
                  When I type "" on application keyboard
                  Then I should see results as ""
              
                  Examples:
                    | unit_type | amount | result |
                    | Inch      |1       | 2.54   |
                    | Link      |1       | 20.1168|
              
                  Scenario: User able to convert values
                    When I press on menu icon
                    Then I select "Volume" from menu
                    Then I select "Cup" from right unit picker
                    When I type "1" on application keyboard
                    Then I should see results as "15.1416"
              
              
                Scenario: User able to switch values
                  Then Left Unit picker value should be "Foot"
                  And Right unit picker value should be "Centimeter"
                  When I press on switch unit button
                  Then Left Unit picker value should be "Centimeter"
                  And Right unit picker value should be "Foot"
              
                  Scenario: User able to cleanup conversion history
                    When I press on menu icon
                    Then I select "History" from menu
                    Then I see "History" as a current unit converter
                    Then I should see text "No history right now"
                    When I press on menu icon
                    Then I select "Length" from menu
                    When I type "1" on application keyboard
                    When I press on menu icon
                    Then I select "History" from menu
                    And I verify that 1st result in history list is "Length"
                    When I press delete from history at 1st row
                    Then I should see text "No history right now"
                
              



Selenium

Unsplashed background img 2

Quix Automation

Using Selenium

selenium-logo
quix-webiste

I created a small test suite in which I test some aspects of a website called Quix, a data streaming page. While the test suite might seem basic, the objective was to show negative and positive test cases, this means that some had to pass and others to fail in order to show the correct behaviour. The test was made with Selenium IDE and the code is written in Python.

Here are some of the test cases I've written:

Login Quix;

python-logo

Case Sensitive Broken;

Alphabetical Selector Broken;

Unable to Edit Code.



...plus manual tests!



Screenshot

Test suite execution

selenium-test
Check out my GitHub project



Code Example:


        
          import pytest
          import time
          import json
          from selenium import webdriver
          from selenium.webdriver.common.by import By
          from selenium.webdriver.common.action_chains import ActionChains
          from selenium.webdriver.support import expected_conditions
          from selenium.webdriver.support.wait import WebDriverWait
          from selenium.webdriver.common.keys import Keys
          from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

          class Test3CaseSensitive():
            def setup_method(self, method):
              self.driver = webdriver.Chrome()
              self.vars = {}

            def teardown_method(self, method):
              self.driver.quit()

            def test_3CaseSensitive(self):
              # Test name: 3-CaseSensitive
              # Step # | name | target | value
              # 1 | open | webiste
              self.driver.get("https://www.quix.io/")
              # 2 | setWindowSize | 2044x1392 | 
              self.driver.set_window_size(2044, 1392)
              # 3 | click | css=.mat-list-item:nth-child(2) > .mat-list-item-content | 
              self.driver.find_element(By.CSS_SELECTOR, ".mat-list-item:nth-child(2) > .mat-list-item-content").click()
              # 4 | click | css=div > .text-truncate:nth-child(1) | 
              self.driver.find_element(By.CSS_SELECTOR, "div > .text-truncate:nth-child(1)").click()
              # 5 | click | css=.mat-list-item:nth-child(2) > .mat-list-item-content | 
              self.driver.find_element(By.CSS_SELECTOR, ".mat-list-item:nth-child(2) > .mat-list-item-content").click()
              # 6 | click | id=mat-input-0 | 
              self.driver.find_element(By.ID, "mat-input-0").click()
              # 7 | type | id=mat-input-0 | transformation
              self.driver.find_element(By.ID, "mat-input-0").send_keys("transformation")
              # 8 | click | css=.w-100:nth-child(2) | 
              self.driver.find_element(By.CSS_SELECTOR, ".w-100:nth-child(2)").click()
              # 9 | assertText | id=mat-input-0 | RESULTS
              assert self.driver.find_element(By.ID, "mat-input-0").text == "RESULTS"
        
      



Other Frameworks

Unsplashed background img 2

Like Xray, Robot Framework... coming soon!



Thanks for the visit! ☺

Feel free to send me an e-mail or connect with me in any social media on top.

Marcelo Costa