BACK

Bot Games Season 2: Auction Sniper Tutorial

Bot Games Season 2: Auction Sniper Tutorial

Challenge Objective

The objective for this challenge is to provide a max bid with as little time left in the auction as possible – reducing in the closest-to-auction-end bid time, and the lowest price paid. Can your bot launch the challenge page…and then wait until the very last second to place a bid? In this tutorial, we’ll break down our bot-building approach to solving this challenge.

Challenge Link: https://developer.automationanywhere.com/challenges/automationanywherelabs-auctionsniper.html

Steps Package

Nothing is worse than looking back at some code you wrote/bot you built 6 months from now and having no idea what the code/bot does or how it works. In a nod to the future you, its best to get into the habit even on fun builds like this of using steps generously. Steps enable you to lay-out your logic in a visible way to build the shell/structure of your bot – going in and filling in the actions required to complete each step afterward. Steps are also a great way to force something we all could do better at: commenting our code. Using steps “forces” code commenting as you give each step a name and fill in the corresponding logic.

While Loop

An event that you know will have an ultimate end is a great use case of a while loop. The code inside of a while loop will continuously execute as long as the condition being evaluated as a part of the while loop resolves to true.

In this scenario, we know that the auction will ultimately hit a 1 or 0 seconds left time, so a great approach here is to continuously extract the time remaining in the auction both before, and while inside of a while loop, so that the value we’re evaluating to see if the while loop should continue executing is constantly updated. Once the condition is no longer true (i.e. the auction time left is down to 0 or 1 depending on how your loop was configured), whatever comes after the While logic would execute…in our case, that means clicking the button to submit the max bid.

String Package

In coordination with the While Loop and Recorder in this build – you’ll likely need to take advantage of some of the actions from the String Package. Specifically, the Extract Text action.

Using this action, developers have the ability to extract text that comes before, after, or in-between static text in a larger string. In our example, we couldn’t just extract the number of seconds left remaining in the auction, we had to extract a larger string that had the number of seconds remaining + the word “seconds”. Since we ONLY want the number for use in our while loop conditional statement, we can extract just the number from the larger string using the “After” capability of this action… to suggest that we only want to extract whatever comes before the word “second” in our example. Doing so should result in a string that just has the “2” if the example input string were “2 seconds”. Once the number itself is extracted (and we’re sure we got only the number without text), the String: To Number action can be used to convert our String of “2” into a proper Number variable that can be used for mathematical conditional statements (like we use in our While Loop in the video tutorial above).

Conclusion

Do something different? Part of the fun of learning to build bots is trying out different approaches to see how they impact the reliability, accuracy, and ultimately the outcome of your bot. What impact would using the Browser: Run JavaScript action have on your bot instead of the Recorder package…are things any faster if you just use the Simulate Keystrokes action instead of the Recorder package? Explore different options as you build these bots as they become different approaches you may consider when building out bots for your organization/customers.

Enjoy doing this Challange Page? Check out some of our other RPA Challenge pages to see if you can knock out some of our other bot-building challenges and check out our other upcoming Bot Games Challenge Pages!