selenium_with_slack

Slack+Selenium: Real-time Automation Results

Using the Selenium and Slack integration, you can post updates to a Slack channel when there are changes in your automated testing results

jslack Java library is a robust library that helps to send real-time information via various Slack channels. Nowadays, the usage of Slack has increased and in high demand for all areas of communication. In automation, the jslack plays an important role to send real-time test execution status, complete results, and report documents. This will helps the management level to evaluate the stability of the applications very quickly. Slack integrations into the automation framework will play a critical role in the upcoming automation world.

Step-by-step Approach to Achieve Real-time Automation Result in Slack Channel

  • Create an account in Slack and then create a Slack workspace. Use https://slack.com/get-started#/
  • Create a Slack application to communicate with your channel about the automation execution status. Use https://api.slack.com/apps
  • Create a Slack channel by clicking plus icon right to Channels in your slack workspace. Keep the Slack channel name in your mind and it useful during the scripting.
  • Add created Slack application to your Slack channel by clicking Add an app link from the slack channel.
  • Go to https://api.slack.com/apps and select your Slack application. Select Incoming Webhooks and activate it. Scroll down the page and you will get Webhook URL for your channel. This Webhook URL is an important parameter in your script which helps to send the messages to your Slack channel.
  • Go to OAuth & Permissions section, there you will get Bot User OAuth Access Token which helps the Slack application to send files into your Slack Channel. Copy the Bot User OAuth Access Token and you can use it in the script.
  • Scroll down in OAuth & Permissions page to reach the Scopes section. Make sure that following scopes are added
    • Bot Token Scopes:
      • file:write
      • incoming:webhook
    • User Token Scopes:
      • file:write

Two Slack utilities have been created to send real-time test results and the test execution reports to the Slackchannel. Following are the methods:

TestStatusToSlack : helps to send the test results to the Slack channel with the help of the Webhook URL and channel name.

ReportToSlack: helps to send the automation test execution report with the help of file upload API, Bot User OAuth Token, and channel name. Following are the detailed implementation of both methods

You must have following dependencies in pom.xml file

Sample Output: Slack Channel