Integrating Selenium with Google DriveCigniti Technologies
Listen on the go!
New-age technologies have extensively impacted our routine activities and quite positively. Today there are sophisticated and advanced gadgets available to further ease human efforts. While the emerging technologies continue to transform our lives, testing their performance for desired outcome is indispensable.
Test Automation holds numerous advantages to enhance the testing processes and achieve maximum test coverage. Google Drive integration is a case in point. We shall further discuss and understand the various advantages of using Google Drive.
When you integrate with the User Interface (UI) of Google Drive, users can create and open files stored on the drive within the application. This process is applicable across all the Google Drive Web applications. The Google Drive platform provides a bunch of APIs along with client libraries, language-specific examples, and documentation to help you develop apps that can integrate with Google Drive for automation.
Why is using Google Drive for Test Automation recommended?
- You can create an external file that stores the test data (Input data and Expected Data) as centralized and shared repository.
- You can populate the test data into Automation Test Script, so that several API’s can be used to read the test data.
- The total number of scripts required to cover all the possible combinations of test scenarios is very less. Thus, lesser amount of code is required to test a complete set of scenarios.
- You get increased flexibility and maintainability of automation test scripts, which also offers a clean and
- Any change in the test data matrix would not hamper the test script code.
- It provides effective communication and sharing, so that it is easier for manual and automation test teams to execute the scripts on Cloud with required set of data.
- Check-in or check-out from the project framework is not required to refactor the test data.
- High re-usability can be achieved, as tests can be reused across multiple test cases by altering the test data values.
Challenges of using Google Drive for Test Automation
- In order to avoid script-processing errors due to incorrect data-file format or content, Notepad or Microsoft Excel has to be used to create and maintain the data files.
- While developing and executing automation test scripts, technical skills are required to refactor the test data sheet within the Automation framework.
Prerequisites for Integration
- Java 1.7 or greater
- Access to the internet and a web browser
- A Google account with Google Drive enabled
Google Drive Configuration
- Login into your Gmail account like email@example.com and navigate to the Access Link https://console.developers.google.com in other tab.
- Click on “Google API Console” under Developer Consoles section at bottom of the page or navigate to link – https://console.developers.google.com/apis/library
- Click on “Drive API” under Google Apps APIs section.
- Create/Select a project in the Google Developers Console and enable the Google API. Click Continue, then Go to credentials.
- At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click Save.
6. Select the Credentials tab, click Create Credentials and select OAuth client ID.
7. Now to create Client Id, click on ‘Configure consent screen’.
8. Select the application type other, enter the name “client Demo”, and click Create.
9. Now dialog will appear which shows your “OAuth Client Id and Client Secret”. Click OK to dismiss the resulting dialog.
10. Select the client name checkbox and click the file download (Download JSON) button to the right of the client ID.
11. Move the downloaded file to your working directory and rename it client_secret.json.
12. Now click on “Create credentials” drop down button and select “Service Account Key”.
13. Select “Service Account – Compute Engine default service account” and key type “P12”. Click Create.
14. Click Close to dismiss the resulting dialog.
15. Move the downloaded file – *.P12 to your working directory.
16. Open Google Drive from your Gmail account.
17. Create a new Google spreadsheet and save it as testSheet.
18. Click Share and share the spreadsheet with your Client Id (xxx-developer.gsserviceaccount.com) which you created above.
19. Modify the Access Link setting – “Anyone with the link can edit”
20. Click Save.
Java Source Code for Integration
Here is a sample code in Java for accessing the Google Drive for any user. To use the same, first download the following jars or add maven dependencies.
- Download google-api-java-client jars from – http://search.maven.org/remotecontent?filepath=com/google/api-client/google-api-client-assembly/1.20.0/google-api-client-assembly-1.20.0-1.20.0.zip
- Extract the downloaded folder and add the following jars in your project:
Google Drive is the most user-friendly storage option, where all test data can be loaded (For e.g. on Gmail, Google Docs, and spreadsheets), and accessed from all remote locations. Google provides both free and paid-for storage services. These provide multiple storage capacity options for your files and folders, where users can store backup local files and sync in files and folders across multiple computers.
It is recommended to utilize Google Drive services for Quality Assurance (QA) practices and further also integrate with Automation tools like Selenium.
Selenium is one of the most popular Automation testing suites. It is designed to test functional aspects of Web applications across a wide range of browsers and platforms. Considering it is an Open-Source platform, it is easy to integrate Google Drive with Selenium. Additionally, credentials of Google account can be shared with all authorized team members for effective execution of tests on the Cloud.
|About the Author: Ashish Jain, Technical Lead at Cigniti technologies, brings with him rich experience in the field of automation for web and mobile-based applications. He has extensive expertise in both functional as well as performance automation. He also holds expertise across various automation tools and technologies and has been involved in designing Testing solutions for various clients in Energy Utilities, Donation and fitness-based domains.|
Cigniti is a Global Leader in Independent Quality Engineering & Software Testing Services with offices in US, UK, India, Australia, and Canada.