Google Translator is an important tool to translate the input text into one language from another language. Google Translator can translate one language to another language for more than a hundred languages. A selenium web driver is a powerful tool, which opens a browser instance automatically and we use it for Google Translator.
What is Selenium?
Selenium is an open-source library that used to automate web browsers. We can use this library in different programming languages like Ruby, Java, NodeJS, PHP, Perl, Python, and C#, among others. Selenium has various tools like Selenium Integrated Development Environment (IDE), Selenium Remote Control (RC), WebDriver, Selenium Grid for different testing needs in the organisations.
To automate the browser we are using the Selenium Webdriver tool. Selenium Webdriver is a web automation framework that executes the test script to open the browser instance for various browsers like chrome, firefox, etc.
How can we use ‘Selenium Webdriver’ to automate Google Translator?
Let’s make a python script for automate the google translator. Follow the below steps to perform this task successfully.
1) Download the Chrome Driver and copied into specific directory.
- Create one Directory and give any name, for example, ‘Google_translator’.
- In the above folder download the Chrome Webdriver by click on the below link for the Ubuntu Operating System. https://chromedriver.storage.googleapis.com/index.html?path=81.0.4044.69/ (You can also find Chrome Webdriver for other operating systems by searching on google.)
- Unzip downloaded ‘chromedriver_linux64.zip’.
2) Open the command prompt and go to the above directory path.
3) Install Virtual Environment.
sudo apt install virtualenv
4) Run below command to create an environment.
virtualenv env_name --python=python3
5) For activating the created environment run below command.
6) Install the required Library for the script.
pip install selenium
7) Create a new python file.
cat > selenium_google_translator.py
8) Copy the following code inside the above file and save the file.
9) Now run the following command.
After running the above script you will get translated output in the command prompt window for the Hindi language for the given input text.
Hope that this tutorial will help you to Automate the Translator!!
Feel free to comment your doubts/questions. We would be glad to help you.
If you are looking for Chatbot Development or Natural Language Processing services then do contact us or send your requirement at firstname.lastname@example.org. We would be happy to offer our expert services.