Posts

Running tests from maven command line: Different options

Image
  When we work on developing automation scripts ,we may sometime need run based on different conditions. Let us see some here. Assuming Prerequisite met for running : Some TestClasses with TestMethods are present in Framework Maven is used as build tool for Framework design. Using TestNG framework for Test Cases The following are the steps: Run specific test from a test class: mvn -Dtest=Testclassname#testmethodname test To run all tests in class: mvn -Dtest=classname test To run test that match a pattern: This will run all tests that starts with  testcreate  in class named  Testclassname mvn -Dtest=Testclassname#testcreate* test Run all test methods match pattern ‘testFoo*’ and ‘testBar*’ from a test class: mvn test -Dtest=Test1#testFoo*+testBar* To run multiple methods in a testclass: mvn -Dtest=Testclassname#testone+testtwo test T o  run Multiple method from multiple class : mvn test -Dtest=CLASS_NAME1#METHOD_NAME1,CLASS_NAME2#METHOD_NAME2 To run multiple tes...

How to compare two images(logos) with selenium

Image
 

How would we make sure that a page is loaded using Selenium and WebDriver?

While automating the script, the tester has to take care that the page is loaded properly otherwise on performing some action execution will fail.  There are some ways defined below to make sure the page is loaded : 1. Using  loading spinner: While the page is loading there is a loading spinner on the web page, the tester can wait for the invisibility of that spinner (new WebDriverWait(webDriver, 120)).until(ExpectedConditions.invisibilityOfElementLocated(by)); 2. By using JavascriptExecutor :  It is an interface which provides a mechanism to execute JavaScript through selenium web driver ((JavascriptExecutor) webDriver).executeScript("return document.readyState").equals("complete")

How to handle random pop ups

Issue:  In some pages unexpected popup's(ex:ad's) will be displaying. Because of this the script will fail by throwing exceptions like  ElementNotFoundException   and currently  Element is not Interactable  etc.. . Here these ad's are not specific to particular page. It may come at any page.   How to handle? A popup can be an alert or an ad in a iframe or an ad in a new window and all these are treated in different ways. Assuming its an Alert, log_file has already provided you the solution, i.e. to use  alertIsPresent () , and accept or dimiss it as per your requirements. Assuming the ad is in  iframe , follow the below approach: driver .switchTo .frame (driver.findElement(By.id(locatorToIdentifyFrame))); driver .findElement (By.id(locatorToCloseAd)) .click (); //Close Ad driver .switchTo () .defaultContent (); // Return to main window Assuming the ad in the  window , follow the below approach: String mainWinHandle = driver.getWindo...

How to handle downloading of different browser drivers without manual intervention?

 Using WebDriverManager, we can automatically download the driver’s binary files (.exe files) for Web Automation Traditionally the binaries are referred as System.setProperty(""""webdriver.chrome.driver"""", """"D:\\test\\chromedriver.exe"""" ); With WebDriverManager, we can eliminate the downloading of the binaries everytime a new version is released. WebDriverManager.chromedriver().setup(); POM: <dependency>   <groupId>io.github.bonigarcia</groupId>   <artifactId>webdrivermanager</artifactId>     <version>3.0.0</version>   <scope>test</scope> </dependency>""

Docker configuration for selenium tests

Image
Why docker for selenium testers: Usually while configuring the Selenium grid we need to host multiple virtual machines as nodes and we need to connect every single node with the hub. Also, when we set up a normal grid we need to download the Selenium server jar file and run that jar file on each computer in which we are going to set up the Selenium grid. This is costly and sometimes a time-consuming task for the testers. However, Docker helps us to solve cost-related and time-consuming problems. Steps to create a automation project with the help of Docker: -Create a Maven project -Add selenium dependencies -Create a class like below.This will print Google by executing test in container created from docker. -Define and initialize a chromeStandAlone container in 4444 port.Below details gives details of docker. Most used common Docker commands: docker ps : Will give information of all containers running in the machine. Docker Images : will show all current images docker pull <image n...

Most common used Docker Commands for SDETs

Image
Why we need docker for selenium Tests: Selenium grid helps to run our test cases in different operating systems and on different browsers.  Usually while configuring the Selenium grid we need to host multiple virtual machines as nodes and we need to connect every single node with the hub. Also, when we set up a normal grid we need to download the Selenium server jar file and run that jar file on each computer in which we are going to set up the Selenium grid.   This is costly and sometimes a time-consuming task for the testers. However, Docker helps us to solve cost-related and time-consuming problems. By using Docker containers we can set up and pack a software application with all of the contents that are required to build that application, such as databases, libraries, and other dependencies, and finally, you can ship them all out as one package. So with the help docker of we can configure the hub and nodes as images which already built in docker hub. So since Docker is a...