Skip to main content

Posts

Eclipse: Refresh workspace automatically

When we run a test case or execute the entire script directly within Eclipse - we would like to see the fresh execution Report or log file or any other refreshed resource but by default, projects don't automatically refresh. I find it very useful to turn on the "Refresh" option so that Eclipse can automatically perform the refresh. This option is shown below: Windows-->Preferences->General-->Workspace-->Select "Refresh using native hooks or polling" I wonder why this preference isn't selected by default when it's very friendly. Check this out to find the difference between "Refresh using native hooks or polling" and "Refresh on access": https://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-9.htm Note* Have heard that at times it does require force refresh on Mac especially with Mars and lesser versions.

Selenium Event Listener

Selenium provides an API for various events that occur when our scripts are executed like click, switch to a window, navigation, onException, etc. and these can be registered using WebDriverEventListener interface or EventFiringWebDriver class. These events play a pivotal role in analyzing results and in debugging issues (if any). EventFiringWebDriver class takes care of all events that are occurred while the execution of your script. EventFiringWebDriver class can be bind to more than one listener but all event listeners should be registered with the EventFiringWebDriver class so that it can be notified. EventFiringWebDriver eventFiring =new EventFiringWebDriver(driver); FirstEventCapture firstListener =new FirstEventCapture(); //FirstEventCapture implements WebDriverEventListener SecondEventCapture secondListener =new SecondEventCapture(); //SecondEventCapture implements WebDriverEventListener eventFiring.register(firstListener); eventFiring.register(secondListener); Check t...

Measuring page load time using Selenium

There are many tools that are designed specifically to measure a load of your web pages such as LoadRunner, JMeter, WebLoad, etc. and preference should be given to these tools only. But in case, there is an ask to do it using Selenium, we can use Performance Timing and Navigation Interface APIs to measure the page load time on client-side: - https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming - https://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface The first image shows when we are executing it manually on the Chrome Dev Tools console. We can use the output generated by these APIs in our Se framework (if required) as shown in the Second Image. P.S. As from Se4 alpha-3 onwards, we can directly play with Dev Tools- I will check if we can directly use it instead of capturing time using these APIs.  #selenium   #loadTime   #devTools   #testAutomation   #seleniumautomation  

The use of Verbose attribute in testNG or POM.xml (maven-surefire-plugin)

At times, we see some weird behavior in your testNG execution and feel that the information displayed is insufficient and would like to see more details. At other times, the output on the console is too verbose and we may want to only see the errors. This is where a verbose attribute can help you- it is used to define the amount of logging to be performed on the console. The verbosity level is 0 to 10, where 10 is most detailed. Once you set it to 10, you'll see that console output will contain information regarding the tests, methods, and listeners, etc. <suite name="Suite" thread-count="5" verbose="10"> Note* You can specify -1 and this will put TestNG in debug mode. The default level is 0. Alternatively, you can set the verbose level through attribute in "maven-surefire-plugin" in pom.xml, as shown in the image. #testNG #automationTesting #verbose # #testAutomation

Jenkins: set of commands to safely stop/restart it

Not sure about you guys but I used to stop/restart Jenkins using cmd prompt only but it looks like we have an optimized way to stop/restart i.e. through the Jenkins instance itself. Jenkins provides a set of commands to safely stop/restart Jenkins by putting it in a quiet mode. 1) quietDown: Put Jenkins in a Quiet mode, in preparation for a restart. In that mode, Jenkins doesn’t start any build 2) cancelQuietDown: Cancel the effect of the “quiet-down” command. 3) safeRestart: Put Jenkins into the quiet mode, wait for existing builds to be completed, and then restart Jenkins. 4) safeExit: Put Jenkins into the quiet mode, wait for existing builds to be completed, and then shut down Jenkins. Just hit these URLs on the browser where your jenkins is running by replacing "<jenkins.server>" with your Jenkins domain URL. http://<jenkins.server>/restart http://<jenkins.server>/safeRestart http://<jenkins.server>/exit http://<jenkins.server>/...

Page Object Model- Selenium

A basic rule of Page Object Model: "If you have WebDriver APIs in your test methods, You're Doing It Wrong" - Simon Stewart A good read: https://www.pluralsight.com/guides/getting-started-with-page-object-pattern-for-your-selenium-tests hashtag # testautomation hashtag # seleniumautomation hashtag # automationtesting hashtag # pageobjectmodel

Selenium 4 Grid

Selenium 4 provides three kinds of Grid- Standalone, Traditional one (Hub, and Node), Fully Distributed (Process and Sessions) Give a shot to Standalone mode where by default, the server will detect available drivers that it can use (Chome, GeckoDriver, etc) by looking at the PATH. Make sure you place all the executable into your PATH. Here's the official link from Se where you can find all the details: https://github.com/SeleniumHQ/selenium/wiki/Selenium-Grid-4 hashtag # selenium4 hashtag # testautomation hashtag # automationtesting hashtag # seleniumgrid