Posts

Showing posts from 2018

Singular Driver Page Object Model

Page Object Model is the framework driven from TestNG framework where every individual Page (screen) is separated in JAVA class. As we all know in Page Object Model test cases are also separated as per screen basis. In this developed framework below mentioned points are considered: Individual screens are separated in each JAVA classes Common selenium methods are stored in separate JAVA class Test cases are also separated as per screen Configurable things are kept apart from non configurable things. For example, URL which can be changed as per env availability is taken care by using config.properties class. Where env key will decide which URL to hit. Cross browser testing is done by using simple config.properties file by specifying Browser key and reading it while launching the browser. TestNG framework is used to create Page Object Model framework Basic TestNG annotations are used Reporting is done via Extents reporting jar No method in classes are static, and Binding is co...

Why WebDriver driver?

As we proceed further to the webpage automation, the important questions arises in mind why always WebDriver driver = new ChromeDriver() / FireFoxdriver() ... and why not to use WebDriver driver = new WebDriver(), or ChromeDriver driver = new ChromeDriver(). 1. Since we can not create object of an Interface as it does not have any constructor, the possiblity WebDriver driver = new WebDriver() is not valid since WebDriver is an interface. 2. If we decided to use  ChromeDriver driver = new ChromeDriver() then our script will only capable of launching Chrome driver and we will not able to handle the multi browser. Since we can not create object of an interface, JAVA still allows to use abstract methods in it. How? The answer is the class which implements an interface will help up to create an object. As ChromeDriver()/ FireFoxDriver()/ IEdriver classes(s) implements Webdriver interface, it is possible to create object of WebDriver with reference of these classes. Hence , whi...

Automation World: How to launch Chrome browser in Selenium

Automation World: How to launch Chrome browser in Selenium : Since Selenium alone is not capable of launching the Chrome browser, we need to take help of third party executable driver which will laun...

Automation World: How to launch Internet Explorer using Selenium

Automation World: How to launch Internet Explorer using Selenium : While launching Internet Explorer using selenium is a tedious job since it involves much of internal security and restrictions. As we have...

Automation World: How to handle Drop Downs using Selenium

Automation World: How to handle Drop Downs using Selenium : Working with drop down options is very easy task when using selenium since we have already drafted method “Select” in selenium. We will us...

Automation World: How to get list of values from Drop down field

Automation World: How to get list of values from Drop down field : Getting all the options from Drop down field is easy task. We need to use method getOptions() which will give list of options in the form ...

Automation World: How to handle Alert using selenium

Automation World: How to handle Alert using selenium : Generally alert pop up are of three types: 1. Alert pop up with OK button 2. Alert pop up with OK and Cancel button 3. Alert pop up ...

Automation World: API Concepts

Automation World: API Concepts : API Concepts: Overview and Target audience: The intend of this document is to provide the basics of API (Application Platform Interfac...

Automation World: How to Setup Jenkins on Windows machine

Automation World: How to Setup Jenkins on Windows machine : Jenkins is most widely used tool for Continuous Integration and Continuous Development purpose. You can schedule your build through Jenkin...

Automation World: How to check if link is broken without opening lin...

Automation World: How to check if link is broken without opening lin... : To test whether link is broken or not without opening it in browser is tedious task. When we are dealing with large number of links on a s...

Automation World: How to Select Date in Date Picker

Automation World: How to Select Date in Date Picker : Selecting date in date picker widget, is exactly same as fetching values from web tables. Date picker is also a web table in kind. so the ...

Automation World: How to read Web Table values

Automation World: How to read Web Table values : To read web tables is something tedious task when dealing with the Selenium. There is no pre-defined class/method which will allow you to ...

Automation World: API Concepts

Automation World: API Concepts : API Concepts: Overview and Target audience: The intend of this document is to provide the basics of API (Application Platform Interfac...

Automation World: How to read values from Config File

Automation World: How to read values from Config File : When we are using / drafting any framework, it is very important that we should keep configurable things/properties separate from static t...

How to Setup Jenkins on Windows machine

Image
Jenkins is most widely used tool for Continuous Integration and Continuous Development purpose. You can schedule your build through Jenkins and trigger can be your deployment. It will automatically schedule the build and even can send the feedback using mail SMTP servers. It is very easy to use any mail server with Jenkins, So that if any of the build fails, it will trig an email notification to target audience. Let’s see how you can configure Jenkins on your windows machine. Step 1: Access the URL  Jenkins site  and locate the  Generic Java Package situated at the bottom. Step 2: Once you finish the download of war file, open the Command prompt and enter  java -jar <location of downloaded war file>  and hit the enter button. Wait until you get below mentioned success message that Jenkins server is up and running. Step 3: Once you get above stated success message, in the browser hit URL  localhost:8080  because Jenkins ...

API Concepts

Image
API Concepts: Overview and Target audience: The intend of this document is to provide the basics of API (Application Platform Interface) on how the communication between two different applications and software’s happen in real world. Since the growing world needs more connectivity between different software’s and which can be achieved simply through standard protocols. Many of the today’s manual testing job opportunities requires API knowledge, since API testing is no longer a skill. What happen if tester is supposed to test an integration and data flow between two different systems when Downstream or Upstream systems are not available? In such cases many of the issues will be undiscovered and will appear during late in the game. Which will cost too much to any project. To overcome this situation, testers needs to have understanding on how API actually works and how communication really happen. In below article you will find basics of API from tester’s point of view. Introducti...

How to Select Date in Date Picker

Image
Selecting date in date picker widget, is exactly same as fetching values from web tables. Date picker is also a web table in kind. so the code explained earlier on on how to fetch values from web table will work here as well. Please find below code to select date in any date picker.

How to read Web Table values

Image
To read web tables is something tedious task when dealing with the Selenium. There is no pre-defined class/method which will allow you to directly access the webtables. We need to create a utility or method which will pull values from webtables and allow you to do more actions on the data. To read values from web tables we will use FindElements and tagName. As we all know that return type of FindElements() is List<WebElements>, it is very powerful media to access the elements. The logic behind accessing table elements is First access the table body. Since WebTable comprises of tbody tag. Access all the rows available in tbody <tr> Access all the columns available for each row <td> Please find below mentioned code to access values from any web tables.

How to read values from Config File

Image
When we are using / drafting any framework, it is very important that we should keep configurable things/properties separate from static things. To elaborate more, consider an example of test data. Test data is non static part of any framework, because it will change for each of regression/ test cycle. So we end up replacing test data after each test cycle. Another example could be web elements. If any change is happening to  UI, it ultimately affects your web elements. So the best practice says keep your static things apart from configurable one. Best part to implement this is to have config.properties file. Its basically a text file which will have values in the format of key and its value. For Example: key1 = value1 key2=value2 We will use Properties class which implements map interface. To create config file, right click on your project > Select file option > save the file with name “ config.properties “. Create a class which will read key from your config f...

How to check if link is broken without opening link in browser

Image
To test whether link is broken or not without opening it in browser is tedious task. When we are dealing with large number of links on a single web page and to check status of each link, a JAVA method HttpURLConnection () will rescue. First identify list of all the links available on webpage. Create a HTTP connection to check whether specified URL gives 200 status or not. If the status is 200 ok the link is not broken.  HttpURLConnection () will check in background if link respond with 200 ok or not. Create below class to create a connection which will return the response 200 Ok or 400: Create another method which will save list of all the links and get attribute “href” out of it, and pass it to above connection method Now check the output. You will get status of each link without opening in browser.

How to Handle multiple Windows

To handle multiple windows using selenium we have 2 pre-defined methods viz, getWindowHandle() and getWindowHandles(). The output of getWindowHandle() is the object or String of current window , while the output of getWindowHandles() is the Set of all the windows opened at that particular time. getWindowHandle()  can be useful to get the object of Parent window while getWindowHandle() gives you parent window as well as child window. So how to switch to child window? The answer is identify from Set which is child instance, since we have saved Parent window earlier. Following code snippet will help to switch to child window and do actions on it and to finally close it. driver.get(“ http://demoqa.com/registration ;); driver.manage().window().maximize(); String parent = driver.getWindowHandle();  // This will save the instance of  current/parent window driver.findElement(By.id(“button1”)).click(); Set<String> childWin = driver.getWi...

How to handle Alert using selenium

Generally alert pop up are of three types: 1. Alert pop up with OK button 2. Alert pop up with OK and Cancel button 3. Alert pop up with OK , Cancel button and Text field to enter values. To deal with alert pop up selenium comes with simple method Alert(); In the first case where we only have OK button below mentioned code snippet will be helpfull. Alert alert = driver.switchTo().alert(); alert.accept(); Above code snippet will switch the control to alert and it will accept it. In the second case where we have cancel button as well, code snippet will be: Alert alert = driver.switchTo().alert(); alert.accept() — To accept the alert alert.dismiss() — To dismiss the alert In the last case where we are supposed to enter some value and click either OK or Cancel , code snippet will be: Alert alert = driver.switchTo().alert(); alert.sendKeys(“value to enter”); alert.accept(); or alert.dismiss();

How to get list of values from Drop down field

Getting all the options from Drop down field is easy task. We need to use method getOptions() which will give list of options in the form of Webelements. We can convert webelement list in String using getText() method and can save it in desired List. Below code snippet will help to get all the options from drop down: Select select = new Select(driver.findElement(By.id(“dropdown_7”))); // This will get all the options from drop down. List<WebElement> list = select.getOptions();   List<String> stringOptions = new ArrayList<String>(); // This will get text from the webelement and save it to some other List for(WebElement s: list) { stringOptions.add(s.getText().trim()); } // This will print all the String options. for(String h : stringOptions) { System.out.println(h); }

How to handle Drop Downs using Selenium

Image
Working with drop down options is very easy task when using selenium since we have already drafted method “Select” in selenium. We will use this method to select the desired values from any given drop down. Below is the snippet of code we can use to select value from drop down. If we observe the browser DOM for any drop down field ,we will get Select tag which specifies the drop down. And since we have id for this particular drop down we can proceed as: Select select = new Select(driver.findElement(By.id(“dropdown_7”))); In above code snippet we have created object of Select method which will accept the argument as Webelement. We can select values from drop down using below mentioned 3 ways: Select By Index  : It will accept integer value and it starts with 0. Select By Value  : It will take value from Value attribute in Select tag. Select By Visible text  : It will take visible text in particular drop down. select.selectByIndex(1);  — This will se...

How to launch Internet Explorer using Selenium

Image
While launching Internet Explorer using selenium is a tedious job since it involves much of internal security and restrictions. As we have seen earlier on how to launch the Chrome browser by simply setting System property and using simple method ChromeDriver(), Internet Explorer do have such kind of method by which we can easily launch the browser. Below code snippet can launch the Internet Explore browser. One can download IE driver from  IE Server Driver  . System.setProperty(“webdriver.ie.driver”, “locale path for IE Server driver\\IEDriverServer.exe”); WebDriver driver = new InternetExplorerDriver(); Code Explanation: First line of code will set the System property as webdriver.ie.driver which will point to the local path where we have downloaded IEdriver.exe. Second line of above code snippet will take use of this property and launch the IE browser, Since we know that selenium alone can not launch the browser. Once the browser successfully launched, one can se...