Skip to main content

Posts

How to Unzip files in Selenium (Java)?

1) Using Java (Lengthy way) : Create a utility and use it:>> import java.io.BufferedOutputStream; import org.openqa.selenium.io.Zip; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream;   public class UnzipUtil {     private static final int BUFFER_SIZE = 4096;     public void unzip (String zipFilePath, String destDirectory) throws IOException {         File destDir = new File(destDirectory);         if (!destDir.exists()) {             destDir.mkdir();         }         ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));         ZipEntry entry = zipIn.getNextEntry();         // to iterates over entries in the zip folder         while (entry != null) {             String filePath = destDirectory + File.separator + entry.getName();             if (!entry.isDirectory()) {                 extractFile (zipIn, filePath);            

Locate disappearing elements

You don't have access to the source code and want to inspect elements like HTML5 validation error messages, Wait icon, dynamic search list, or for that matter any disappearing element in your browser that disappears when your mouse moves away?  There are many ways to do that but using below we should be able to capture most of those kinds of disappearing elements/scenarios: Open Chrome Go to that page where you would like to inspect the disappearing element Open dev tools (F12) Select the "Sources" tab While the element you want is displayed, press F8. This should halt the script execution by freezing the DOM (Paused in debugger mode) As the DOM is in the frozen state, now we should be able to hover/select that element to inspect that. #smallAndOldTip #TipsAndTricks #testAutomation #devTools

Where should we keep sensitive information in automation projects?

Of course, nothing can beat encryption/decryption to safeguard our sensitive data but here is one more approach to store your project data and retrieve. Environment Variables are key/value pairs like Properties. We can use this to allow config (sensitive) information to be passed into applications. We can use it in any automation project, not necessarily for Selenium only. Like every approach this too has it’s own pros and cons but for sure, it’s better than keeping your sensitive date in code directly or in a property file. Good read by Alex — https://medium.com/@alexsiminiuc/in-selenium-projects-keep-sensitive-information-in-environment-variables-3c9eb6521080

To perform data-driven testing- which is better (UI/API)?

For sure we can do data-driven testing using automated UI tests (Selenium, Cypress, WebDIO, etc.) but just because it gives us the option, doesn’t mean that we should it for all cases through UI only. Take an example where we visit any website to get a price quote on any policy — let’s say a medical policy, what do we do- we run our test by going through the same page(s) like select value from few dropdowns, select few checkboxes, and enter values in few text fields to get one final output i.e. the “ price quote ” of your medical policy- here the variation was only the “ Test Data ” that finally derive a  certain output . Don’t you think that to test this business logic, the efficient way would be to perform API testing which is better maintainable and powerful? As I mentioned in my previous post too, our UI (end to end) should be meant to confirm that user(s) can use our application in the way it’s intended to do so, perform interactions with it without hitting any issues and always w

Mock GeoLocation using Selenium 4

If there is a use case where you need to override the geolocation of the browser before you hit the website, Selenium 4 Alpha version does support that now by using the power of Chrome DevTools and Protocol (CDP) along with setGeolocationOverride method present in Emulation class. To set it back to default, use the clearGeolocationOverride method. #mockGeoLocation #testAutomation #selenium4Alpha @Test private void testGeo() throws InterruptedException { driver .get( "https://www.google.com/maps?q=28.704060,77.102493" ); Builder<String, Object> mapLatLan = new ImmutableMap.Builder<String, Object>(); mapLatLan .put( "latitude" , 40.712776); mapLatLan .put( "longitude" , -74.005974); mapLatLan .put( "accuracy" , 100); ((ChromeDriver) driver ).executeCdpCommand( "Emulation.setGeolocationOverride" , mapLatLan .build()); driver .get( "https://www.google.com/maps?q=40.712776,-74.005974&q

Adaptive Wait in TestProject

Wait for a certain condition(s) like eg. click, type, etc. to meet and then perform an action is required in almost every UI automation test case. And most of us break our head too much on playing with different dynamic (async) waits which are never-ending practice especially when you have a common framework for your m site as well as your desktop browsers. When I saw that TestProject announced something called Adaptive wait Capability, I tried it and it works wonder. So, if you are already using TestProject, give it a shot. Must say that Adaptive Wait = Smart wait here. Especially when we struggle too much due to different net speed/connections and device physical resources bottlenecks. Check their official documentation for the same here: https://docs.testproject.io/tips-and-tricks/explicit-wait-and-adaptive-wait and https://blog.testproject.io/2020/05/04/testproject-adaptive-wait-capability/ hashtag # TestProject hashtag # automation hashtag # AdaptiveWait

Roles and Responsibilities of QA in Scrum

Created this deck last year: "Roles and Responsibilities of QA in Scrum" Please share your thoughts if you see something terribly wrong and name it. If you have anything to add, I’d love to read and discuss it. hashtag # qa hashtag # agile hashtag # agilemindset hashtag # agileteams