Getting Started with Tauk Assistant

Ranvir Chhina
Tauk Blog
Published in
5 min readJul 6, 2022

Tauk Assistant is a helper tool that can be used in conjunction with the Tauk Python Package to obtain JavaScript errors from the console and to obtain browser warning logs and other additional information directly from the Web Browser during a Selenium test. It is a binary which is supported on Windows, MacOS and Linux. It can be installed using the Tauk Python Package command line interface.

In this short guide, I will demonstrate how to install Tauk Assistant and how to set it up so that it hooks into the lifecycle events of your Selenium tests. Once that is done, I will head over to the Tauk Web UI to show where the relevant attachments captured using Tauk Assistant can be downloaded for your test.

Installing Tauk Assistant

Navigate to the Python project which contains the Selenium Automation suite that you want to use Tauk Assistant with. If you have not already done so, you will need to install the Tauk Python Package. This can be done using the following command.

To verify that the installation worked, try running the following command.

If you see command output which is similar to the above example, you can proceed to the next step.

Next, navigate to the Tauk Web UI and click on the User Settings button on the lower left of your screen.

Click on the API Access > Show button to get your Tauk API Token. Copy this Tauk API Token and save it for future use.

Now, we will use the tauk module command line interface to install Tauk Assistant. You can use the following command to the download and install the Tauk Assistant binary. This step will require you to enter your Tauk API token that you received in the previous step.

The flags for the assistant command have the following meanings

  • The -i flag installs the Tauk Assistant binary
  • The -t flag plugs in the API token which is necessary to download the binary from Tauk.

After the above command finishes execution, the Tauk Assistant should be installed on your local machine. This step downloads a binary for your specific platform and installs it. As it sets up the Assistant on your machine, depending on your platform, it might require you to give it permission to continue installing.

Enabling Tauk Assistant

To be able to use the Tauk Assistant in your test execution, you will also need to configure it in your TaukConfig object. The Assistant object keeps track of the Assistant executable path. By default, your PATH will be checked to see if the Tauk Assistant is there. If you’ve performed a custom installation and put it in a location that’s not accessible in your PATH, you can manually set its location path in code or as an environment variable.

The simplest way to configure the Tauk Assistant is through the code and can be done as shown in the following example.

The third line allows you to set the assistant’s executable_path. If you installed the Tauk binary using the steps above, the binary should be located in you %HOME%/.tauk/binaries directory.

You can even modify this assistant config by calling some predefined methods on the assistant_config object. Some examples include the following.

You modify the Tauk Assistant config to suit your needs.

Running a Selenium Test with Tauk Assistant

Let us write a sample selenium test and use the Tauk Assistant to capture console logs for that website. To illustrate the console errors captured during the text execution, we will pick a website which has a lot of content and potential to emit console errors. An example would be the Washington Post website.

In the __main__ method,

  • We setup the TaukConfig and enable the Tauk Assistant by setting the config.assistant_config property.
  • We set up the unittest.TestSuite with a TaukListener. This allows Tauk to hook onto the unittest lifecycle events.
  • We set up a basic test case to open the Washington Post website in the test case test_open_washington_post method.

You can run this python module to run the test case.

Downloading Attachments in the Tauk Web UI

Now that you have a test case which runs the Tauk Assistant, you can go and download the corresponding attachments from the test run. Go to the Web UI and open the test report corresponding to the test that you ran in the previous section.

Within this page on the top right click on the Attachments button. This should open a modal with the available attachments for this test run.

You can download the raw browser logs corresponding to this run from this modal. In a similar fashion, if you enable the console logs or alter the log level, you would be able to see the corresponding attachment available for download in this download modal.

Conclusion

Even though Selenium tests are widely used in smoke testing of websites, there is no way to download the console logs for a selenium session. The Tauk Assistant provides a clean interface to capture console or browser logs for your test runs. It bridges the Chrome DevTools protocol with your Selenium session and abstracts this middleware in code allowing the user to only worry about higher level configuration.

Lastly, if you have any questions about this blog post, you can reach out to us by joining our Discord server:

--

--