To be able to work with web automations, we need to use the corresponding WebDriver to communicate with browsers for automation.
In doing so, it requires that the WebDriver for the chosen browser to be installed and available preferrably
in your PATH. If you can't add the necessary WebDriver to your PATH you will be able to inform the driver path
via code in your bot.
Here is a list of supported browsers along with links for you to download the proper WebDriver:
With cookiecutter properly installed, it is time to make use of it and create a new project.
To create a new project using our template we will invoke the cookiecutter and provide as argument the URL in which the templates from BotCity is located:
Under your project folder HelloWebBot you will have the following structure:
HelloWebBot
├── bot.py <- Here is where you will develop your bot code.
├── resources <- Folder containing resources useful for the Bot.
├── build.bat <- Batch script to generate the package.
├── build.ps1 <- PowerShell script to generate the package.
├── build.sh <- Shell script to generate the package.
├── requirements.txt <- File describing the python dependencies for your Bot.
└── HelloWebBot.botproj <- File used to load the project on BotStudio.
Note
It may seem like a lot of files and folders but here are the most important ones:
bot.py: Change this file and add here the code for your bot.
resources: Add into this folder files to be used with your bot such as images, spreadsheets and etc.
requirements.txt: Change this file and add all external dependencies that are used in the code.
Great!
All this information is great but it is time to see some action.
As mentioned before, to be able to use the web framework features, it is necessary to configure the WebDriver path of the browser we are using.
If you don't have the WebDriver path added to your PATH, you can manually add the path in your bot code, via the driver_path property.
...defmain():bot=WebBot()# Configure whether or not to run on headless modebot.headless=False# Changing the default Browser to Firefoxbot.browser=Browser.FIREFOX# Setting the path of the Firefox WebDriverbot.driver_path="<path to your WebDriver binary>"...
Info
Chrome is set as the default browser. To change the default browser, just select another option through the Browser class.
Now it is time to load your project with BotCity Studio and start creating your automations with Computer Vision and all the productivity offered by our tool.