Skip to main content

Posts

@FindBy Limitation to accept only Static String

Completely agree with Simon, we should get something better here. @FindBy annotations accept String constant values. You can't compute them at runtime and always have to go with mix and match approach here like PageFactory annotations for static ones and By's in for dynamically created element(s). There are few workarounds that we’ve tried but nothing solid yet. hashtag # FindBy hashtag # testautomation hashtag # Selenium

Screenshot using Chrome DevTools

1. Open a Chrome browser. 2. Open Dev Tools (Press F12). 3. Press CTRL+SHIFT+P (in windows) or cmd+SHIFT+P (in mac). 4. Type "screenshot" into the Command Menu and you will see options like "Capture area screenshot", "Capture full-size screenshot", Capture node screenshot" and "Capture screenshot". 5. Select your desired option and hit enter. Done... If you wish to, you can also emulate a device mode first and then take the screenshot- this way it will capture as per the device dimensions. Isn't it really handy when you want to take the screenshot of the entire page on any device like iPhone X?

Zoom In And Zoom Out In Selenium using JavascriptExecutor

Zoom In And Zoom Out In Selenium using JavascriptExecutor: public void zoomInOut(String value) { JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("document.body.style.zoom='" + value + "'"); } And use the above function as per your need like: public void validateZoom() { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("https://testersdigest.blogspot.com"); zoomInOut("150%"); zoomInOut("10%"); zoomInOut("40%"); }

Automation Test Data using jFairy

A few weeks back, I wrote about how we can come up with the automation test data that look more or less like real application data. There we have discussed the test data generation library Java Faker: https://testersdigest.blogspot.com/2019/10/automation-test-data.html (https://github.com/DiUS/java-faker).  We have a similar Java library "jFairy" which can generate test data for our automation scripts: https://github.com/Devskiller/jfairy Usage of jFairy is quite simple and similar to java-faker. #automationTestData   #JFairy   #testautomation   #automationTesting  

Code Review: SonarQube

The automation scripts that we write might not go to production but it ensures that high-quality product is pushed into Production. So, we all should use Static Code Analysis tools like SonarQube, SonarLint, etc. that helps us: - detect any potential bugs and performance issues, security vulnerabilities - meet the code quality, detects the duplicate code and help detects the complexity level of the code logic, etc. And with the advent of docker, it's super easy to install and play with it, like for SonarQube: https://hub.docker.com/_/sonarqube/ #automationtesting   #sonarqube   #dockerSonarqube   #codereview

How to make sure that your Selenium automation test works fine even for slow loading web pages?

Rather than using methods like waitForPageToComplete() or document.readyState property etc. to wait for a page to load in your Se tests, the better way is to use the LoadableComponent and SlowLoadableComponent pattern in Page Object Model. You need to make sure that your Page Object classes extends the abstract LoadableComponent class which in turn provides the implementation for the following methods: - load() //The load method is used to navigate to the page - isLoaded() throws java.lang.Error //The isLoaded method is used to determine whether we are on the right page. The get() method from the LoadableComponent class will ensure that the page/component is loaded by invoking the isLoaded() method. If the check fails here, load() method is called followed by isLoaded(). If your site loads very slow, then we should consider using SlowLoadableComponent instead of LoadableComponent. SlowLoadableComponent verifies the page is loaded until the given maximum timeout....

Fillo: Query your excel

Recently came across a really cool Java API called Fillo. It is an open-source API that lets you query Excel files (xls & xlsx) and it supports select, insert & update queries. Maven dependency for Fillo: https://mvnrepository.com/artifact/com.codoid.products/fillo My requirement is to fetch the APIs Name where Type=Regression and Run=Yes from below shown Excel table. I have given a shot to simple queries and it works fine. Please check more details here: https://codoid.com/fillo/ P.S. I'm a strong believer in 'we should use Public APIs instead of creating utilities from scratch' unless we have some other restrictions like legal etc. #testautomation   #automationtesting    #tipsandtricks   #fillo   #queryExcel