Git Product home page Git Product logo

emc-test's Introduction

Playwright EMC -TEST

Table of Contents

Description

  • Using a JavaScript-based automated testing tool of their choice;

  • Navigate to https://www.medicines.org.uk/emc/browse-companies

  • For each page of the company browser

  • Capture details about the first, the third and the last company on the page. The details must include the company name, the logo and all contact information.

  • Do not capture the information about the drugs related to that company

  • Store the logo as an image in a folder

  • Add the company details to an internal data structure. Include the filename of the image file

  • Output the internal data structure of the company details as a JSON or XML file.

Prerequisites

Before you begin, ensure you have Node.js and npm installed on your machine. If not, follow the installation instructions provided in the Node.js Package Manager Installation Guide.

- Please note that several downloaded logo images are stored in the 'image' directory, and the most recent JSON file is located in the 'results' directory.

Installation

cd playwright-emc-test
  • Install the dependencies and the browsers.
npm install && npx playwright install
  • Run the test.
npx playwright test
  • Run the test in non-headless.
npx playwright test --headed
  • Report the test result.
npm run report
  • Json file and Image Folder.
View the results folder for Json File
View the image folder for downloaded logos

Test

Overview

This testing approach was founded on the premise that the structure of company details is well-defined, allowing for the establishment of a clear schema. This assumption is based on the need for consistency with existing schemas, ensuring backward compatibility and integration with other systems.

Defining a Schema

To maintain strict typing and structure, we defined a CompanyDetails type, capturing essential information about a company:

export type CompanyDetails = {
  Name: string;
  Address?: string;
  Email?: string;
  Logo?: string;
  Telephone?: string;
  Fax?: string;
  Website?: string;
  MedicalInformationFax?: string;
  MedicalInformationDirectLine?: string;
  MedicalInformationEmail?: string;
  CustomerCareDirectLine?: string;
  OutOfHoursTelephone?: string;
  OutOfHoursContact?: string;
  AdverseEventReportingEmail?: string;
  AdverseEventReportingTelephone?: string;
  StockAvailability?: string;
  DrugSafetyEmail?: string;
};

This structured approach ensures that each piece of company information adheres to the defined types, enhancing data integrity and type safety.

Handling Duplicates and Varied Data Sources

During the extraction of company details from the DOM, we encountered instances of duplicate entries and varied data formats (such as text within <span> tags and email addresses within <a href> tags). To address this:

  • We implemented checks to append values for duplicate keys, ensuring no data is lost.
  • We differentiated between text and hyperlink values, extracting the relevant information accordingly.

Optimizing Resource Usage

To optimize performance, particularly concerning image downloads, we implemented a check to avoid re-downloading existing logos. This not only saves bandwidth but also reduces the overall execution time of the tests.

Alternative Approach

An alternative approach could have been to forego a predefined schema and dynamically populate company details as encountered. For instance:

const companyDetails: CompanyDetails = {
  Name: "XXXXX Company",
  Logo: "logo.png",
  Website: "https://XXXXX.com",
  ContactMethods: [
    { type: "Telephone", value: "123-456-7890", description: "Company Telephone" },
    { type: "Email", value: "[email protected]", description: "Email" },
  ],
};

This method offers flexibility and is particularly useful in scenarios where the data structure might not be well-defined or subject to change.

Conclusion

The chosen implementation strategy—whether it is a structured approach with a predefined schema or a more dynamic method—depends on the specific requirements and constraints of the project. Both strategies have their merits and can be selected based on the need for schema consistency, flexibility, and data integrity.

emc-test's People

Contributors

olufemiadeolusile avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.