Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    hyperlocal-marketplace-guide

    Language File Conversion in CS-Cart using Selenium WebDriver

    Introduction

    Converting the language file of CS-Cart add-on into any desired language of the user choice is time taking.

    If we do it manually and to test that desired add-on into any language of the user choice is important nowadays, as a customer can require the add-on in any language of his choice, so to make our add-on compatible according to their language is quite important.

    Therefore, we have created a small automation program for converting CS-Cart language file into any desired language file of the user’s choice.

    Steps to Convert the Language File

    Create a New Maven Project

    If we create a Maven Project then we don’t have to add all jar files into the library which are needed for our project.

    It will automatically download and add all the jar files into your project which are required by just adding the dependencies into the POM.xml file of your project.

    Create a New Package

    After the above step create a new package under our project by any desired name of your choice. The package which you are creating is a user-defined package which will create a folder in your workspace.

    Create a New Class

    After creating the package you have to create a class under the package which you have created in above step. A class is a user defined prototype from which objects are created. We can also create an object of a class and access it from another class.

    Create a Function to Get Files

    We will declare all the variables at once before using them in any method using the Private modifier. We don’t have to declare any variable again and can use it anywhere inside any function of our project.

    First enter the path of the folder where input files has been kept. After-that, enter Output folder location where output files will be stored. You should have ChromeDriver file according to the OS you are using and should enter whole path with file name.

    Note: In case you are using another browser you have to change the code accordingly.

    Now pick default English language file from given location using File class. In case of multiple files we will store it in an array to convert each file.
    Pick each file from the input location and copy the name of that language file. And create a converted language file at the Output location. If the file with same name will be present then it will delete that language file and create a new language file.

    At the end of this function we will call another function while passing parameters and converting that parameters to the string and return success.

    Now ask the user in which language he wants to convert the file using Scanner Class.

    Now read the file by line using readLine() method if it’s not null than we will start a loop. After-that we will find the text which we want to convert using Pattern class. Which is used for regular expression with the help of matcher class which matches entire input sequence against the pattern.
    The find() method of matcher Class attempts to find the next sub-sequence of the input sequence that find the pattern and then store the result into a string variable ‘wk_resultText’.

    If ‘wk_resultText’ is not null than we will call the method which will open the Chrome browser using WebDriver . We will pass the path of the ChromeDriver stored in our workspace while calling the function.

    Now in this SetBrowser() function we are setting the property of the ChromerDriver and giving the location of ChromeDriver in our workspace so it will open the Chrome Browser and then maximise it.

    Now we will call other function TextConvert() after opening the Chrome Driver then we will give the url of Google in driver.get() method then we will find the input field of Google by using xpath.
    Now we will send the text into the input field using sendKeys() method and we will click on Search button of Google by finding the path of the Search button using xpath.

    Google Translate page will be opened according to the language which user has selected for converting the language file.
    We will find the location of text area using xpath where we will enter the text which need to be converted and will send the text using sendKeys() method.

    We will wait until Translated text-area is visible for picking up the value using xpath with the help of ExpectedConditions.visibilityOfElementLocated of WebDriverWait which is used to wait for an element to be visible on the page. After that we will get the text using getText() method and store them into a String variable ‘getConvertedText’.

    After this rest of the lines in the English Language file will be paste as it is using BufferedWriter class to write the line into the output file.

    After all this, main() class will be called and then whole process will work according to it.

    Create jar file of your project and run it from Command Line by going to the specific location where you have stored your jar file and run the command java –jar FileName.jar.

    When you enter this command then it will ask you to enter Input, Output and ChromeDriver location.

    After providing the path of the folder it will ask you to enter the Language in which you want to convert.

    When you provide language input than chrome browser will start automatically and then your project will execute according to the program which you have written and in output folder your files will be shown with converted language.


    In case you have any queries then feel free to ask in the comment section below.
    This is all about CS-Cart Language Conversion through Selenium WebDriver.

    Thanks for reading this blog

    Happy testing!!

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close