Skip to content

ceacosta-git/selenium-google-finance

Repository files navigation

Pre-requisites

This project was tested with

  • python 3.12

How to run in github

  1. Navigate to Run Selenium Tests Nightly action
  2. Click Run workflow dropdown
  3. Use workflow from Branch: main
  4. Choose which tests to run
    1. all runs all tests
    2. print_differences runs test case 5 and 6 from Problem #1
  5. Click Run workflow button run_tests_github.png
Note: This workflow also runs automatically nightly at 10pm PST

How to run locally

  1. Clone this repo: for example
git clone https://github.com/ceacosta-git/selenium-google-finance.git
  1. Navigate to selenium-google-finance project on your local environment: for example
cd ~/dev/selenium-google-finance
  1. Use pipenv for setting a local virtual environment
    1. Pre-requisites:
      1. Install python
      2. Install pip
    2. Install pipenv
    pip3 install pipenv
    
    1. Install dependencies using Pipfile pipenv install
  2. Run tests
    1. Running all tests
    pipenv run python -m pytest --verbose --html=reports/report.html --self-contained-html -s
    
    1. Running print_differences (test case 5 and 6 from Problem #1)
    pipenv run python -m pytest -m print_differences --verbose --html=reports/report.html --self-contained-html -s
    

Tech Stack

Test Google Finance page

Problem Statement

Write an automated test for a web application using Python and Selenium using Page Object and Page Factory models.

Problem #1:

Retrieve data from UI and compare against the following test data:["NFLX","MSFT", "TSLA"]

Instructions:

Write a test that:

  1. Navigates to Google Finance page on a Chrome browser.
  2. Verifies the page is loaded by asserting the page title contains Google Finance
  3. Retrieves the stock symbols listed under the section “You may be interested in info” stocks.png
  4. Compare the stock symbols retrieved from (3) with given test data
  5. Print all stock symbols that are in (3) but not in given test data
  6. Print all stock symbols that are in given test data but not in (3)

Problem #2:

Create GitHub Actions workflows for manually and nightly runs.

Manual workflow should have option to run full set of test or test case 5 and 6 from Problem #1.

Solution

The main solution for Problem #1 was implemented in tests/google/test_finance_page.py

The main solution for Problem #2 was implemented in .github/workflows/nightly_test_run.yml

Follow-ups

  • Allow to specify headless or non-headless browser option through a pytest flag
  • Support and specify other browsers such as Firefox
  • Setup and run this project using Docker
  • Investigate if we can run non-headless in github

References

As a refresher on Selenium with python, the following references were extremely useful:

About

A sample test framework in Selenium and Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages