Integrating Selenium with Google Drive
Integrating Selenium with 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.
Join the DZone community and get the full member experience.Join For Free
SnapLogic is the leading self-service enterprise-grade integration platform. Download the 2018 GartnerMagic Quadrant for Enterprise iPaaS or play around on the platform, risk free, for 30 days.
Technology has majorly impacted our existence, as today there are sophisticated and advanced gadgets available to further ease our lives. While the emerging technologies continue to transform our lives, testing their performance for the desired outcome is indispensable. Test automation holds numerous advantages for enhancing the testing processes and achieving maximum test coverage. Google Drive integration is one of them.
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 of 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 with automation.
Why Is Using Google Drive for Test Automation a Great Idea?
You can create an external file that stores the test data (input data and expected data) as a centralized and shared repository. You can populate the test data into an automation test script so that several APIs can be used to read the test data.
Additionally, the total number of scripts required to cover all the possible combinations of test scenarios is less. Thus, a lesser amount of code is required to test a complete set of scenarios.
You also get an increased flexibility and maintainability of automation test scripts, which also offers a clean and user-friendly interface. 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 a Cloud with required set of data. You are not required to check-in or check-out the project framework to refactor the test data.
Finall, high reusability 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. Additionally, 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 and navigate to the Access Link in another tab.
- Click on Google API Console under the Developer Consoles section at bottom of the page or navigate to this link.
- Click on Drive API under the Google Apps APIs section.
- Create or 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 your 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 showing 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 the 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 the Client Id (xxx-developer.gsserviceaccount.com) that 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 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 this link.
- 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 (i.e., Gmail, Google Docs, and spreadsheets) and is accessible from all remote locations. Google provides both free and paid 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 folks for effective execution of tests on the Cloud.
Published at DZone with permission of Ashish Jain . See the original article here.
Opinions expressed by DZone contributors are their own.