0% Complete

Introduction

This lesson will help you learn the basics of working with the mabl command-line interface.

Before taking this lesson

Make sure you are comfortable with the following lessons:

  • mabl App Intro
  • mabl Trainer Intro

Learning Objectives ๐Ÿง 

By the end of this you will understand:

  • Why and when to use the CLI
  • How to inspect mabl configuration ๐Ÿ”
  • How to run tests locally ๐Ÿ’ป and on the cloud โ˜๏ธ
  • How to author and edit tests โœ๏ธ

Are you ready to supercharge your day with the powers of the CLI? ๐Ÿ’ช

Why is this important?

Why Would I Ever Want a Command-Line Tool?

The mabl CLI...

  • gives you quick access to mabl functionality ๐ŸŽ
  • is a great alternative for repetitive tasks
  • may be used in scripts

Let's get started! ๐Ÿ

What is it?

The mabl CLI is a NodeJS application that runs in the terminal window on your own desktop, and allows access to most mabl functionality and can be invoked from scripts.

Getting started

First, letโ€™s install it

  1. Install NodeJS 10.x or later. You can download the installer here.
  2. Open up a terminal window or Command Prompt
  3. Install the CLI using npm i -g @mablhq/mabl-cli

โœ… First challenge completed. Ready for more?

Command Structure

You supply a command to the mabl CLI. Each command has arguments, some of them may be the same as in other commands, but some are command-specific. Both mabl tests list and mabl plans list support the --limit argument.

You can see the list of commands by running the mabl command without any options, and the available arguments for each command using mabl command --help.

mabl cli gif1

Let's jump in!

Login ๐Ÿ”

Before you can interact with mabl, you have to authenticate using the mabl auth login command. Your session will remain valid for 4 hours. ๐Ÿ•“

mabl auth info allows you to verify that you are logged in and the time left in your session.โณ

 

You may also have to change configuration defaults with the mabl config command that we will cover in the next lesson.

Youโ€™re in? Letโ€™s move on...

Commands, Arguments, Optionsโ€ฆ.

If your head is spinning, not to worry...

The mabl web app comes to the rescue! โ›‘

Navigate to the test detail page under Tests, and notice the >_ icon that shows how to invoke the CLI.

Ready to ๐Ÿƒ๐Ÿฝโ€โ™€๏ธ a test?

Running Tests

The mabl run command allows you to run tests locally on your machine. 

The test will spin up a new instance of a browser and you can see all the browser interactions as the test runs.

Is that browser getting in the way? Use the --headless option to hide the browser window while you work on something else.

mabl cli gif2

Do you want to get creative? ๐ŸŽจ

Creating Tests

The mabl tests create command allows you to quickly create a new test: it only takes an application URL and a test name to get started.

For more granular control, you may set the application, environment, etc - but now you know how to query all those arguments, right?

mabl CLI gif3

One last thing before we go!

May I See Your ID? ๐Ÿ‘ฎ๐Ÿป

Many mabl commands use IDs to identify applications, environments, etc.

The list command comes to the rescue

In addition, the mabl UI can also help when you visit the mabl CLI section in the Settings -> APIs page.

Letโ€™s recap!

Recap

Reflect

  • You learned how to install and perform basic functions of the mabl command-line interface.
  • Now you know that the CLI helps to work with mabl tests from the convenience of the command-line and to repeat frequently used operations.
  • Tests running locally in headless mode execute faster in the background.

One last tip: keep the documentation page handy when working with the CLI.

Stay tuned for the sequel where we go into more depth on the mabl CLI! ๐Ÿฟ

Feedback

Was this helpful?

Take this 2 minute survey to let us know how we can make mablU better!