Latest Trends in Software Testing – 2017

Automation testing is among the top in the list of Latest Trends in Software Testing for Year 2017.

Apart from automation testing, there is Agile, DevOPs, Big Data testing, New technologiers like SOA, mobile testing, cloud testing etc. Let us has look on it.
Latest Trends in Software Testing 2017

Automation Testing (Among Top on Latest Trends):

Since last 2 years, Automation testing is growing day by day & all the companies want to automate their applications so as to get testing (might be regression) done fast / reduce cost. Here is the list of trending tools in Automation testing area.
          a.       Selenium WebDriver (Including TestNG, JenkinsCI, Maven etc.)
          b.       BDD testing
          c.       Mobile application testing (tools like Appium)
          d.       Agile Frameworks
          e.       TOSCA
          f.        UFT
          g.       Test Complete

Agile:

It’s a set of methods around iterating and making incremental development with changing (well, evolving) requirements and solutions. Basically, it means being flexible and changing to the needs of the project over it’s life and to listen to the customers.

Advantages of Agile Model:

 The most important of the advantages of agile model is the ability to respond to the changing requirements of the project. This ensures that the efforts of the development team are not wasted, which is often the case with the other methodologies. The changes are integrated immediately, which saves trouble later. There is no guesswork between the development team and the customer, as there is face to face communication and continuous inputs from the client. The documents are to the point, which no leaves no space for ambiguity. The culmination of this is that a high quality software is delivered to the client in the shortest period of time and leaves the customer satisfied.

DevOPs:

DevOPs is a culture, A healthy culture of the organization in which development and operations team to work with each other.
The Process of Development -> Test -> Deploy -> Monitor – > Support should be as smooth as possible.
DevOPs talks about writing test cases before you code, this helps to increase the quality of the product, definatly resulting less bugs.
DevOPs talks about automation, Automation as much as you can.
DevOPs talks about culture in which people should be open minded, transparent, egoless, professional etc..
This was about Latest Trends in Software testing in year 201.
Hope This Helps !!!!

What is actions class in Selenium WebDriver?

Actions class in Selenium WebDriver –

In Webdriver, handling keyboard events and mouse events (including actions such as Drag and Drop or clicking multiple elements With Control key) are done using the advanced user interactions API . It contains Actions and Action classes which are needed when performing these events.

In order to perform action events, we need to use org.openqa.selenium.interactions.Actionsclass.
We need to use perform() to execute the action.
Using Action API, keyboard interactions are simple to do with webdriver. In Advanced User Interactions API, interaction with element is possible either by clicking on element or sending a Keys using sendKeys()
To use mouse actions, we need to use current location of the element and then perform the action.
The following are the regularly used mouse and keyboard events:
Method :clickAndHold()
Purpose: Clicks without releasing the current mouse location

Method : contextClick()
Purpose: Performs a context-click at the current mouse location (double click).

Method: doubleClick()
Purpose: Performs a double click at the current mouse location

Method: dragAndDrop(source,target)
Parameters: Source and Target
Purpose: Performs click and hold at the location of the source element and moves to the location of the target element then releases the mouse.

Method : dragAndDropBy(source,x-offset,y-offset)
Parameters: Source, xOffset – horizontal move, y-Offset – vertical move Offset
Purpose: Performs click and hold at the location of the source element moves by a given off set, then releases the mouse.

Method: keyDown(modifier_key)
Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONROL)
Purpose: Performs a modifier key press, doesn’t release the modifier key. Subsequent interactions may assume it’s kept pressed

Method: keyUp(modifier_key)
Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONROL)
Purpose: Performs a key release.

Method: moveByOffset(x-offset, y-offset)
Parameters: X-Offset , Horizontal offset, a negative value means moving the mouse to left side.
Y-Offset, vertical offset, a negative value means moving the mouse to up.
Purpose: Moves the mouse position from its current position by the given offset.

Method: moveToElement(toElement)
Parameters: toElement – Element to Move to
Purpose: It moves the Mouse to the middle of the element.

Method: release()
Purpose: It releases the left mouse button at the current mouse location.

Method: sendKeys(onElement, charSequence)
Parameters: onElement, which will receive the keyStrokes, usually text field.
charsequence- any string value representing the sequence of keyStrokes to be sent.
Purpose: It sends a series of keyStrokes onto the element

As mentioned above, we can use Actions class for following actions –

Hope This helps !!!

MouseHover action in selenium WebDriver

Mousehover action in selenium WebDriver –

In the Actions class, the user, can perform one action, by simply calling it into the driver instance, followed by the method perform().

MouseHover using Actions Class in Selenium WebDriver

Let us see about mousehover action in selenium. If the menu bar or anywhere on the page, the menu has dropdown, and the dropdown options appear only when you hover the mouse on that menu.

So, in this case, we can use mouse hover action of the Actions class in selenium

Let us see, hot this can be achieved.

In my blog (URL: http://automationtalks.com/), suppose you want to select the sub-menu (Selenium WebDriver) of Menu: Selenium.

See below screen.
MouseHover using Actions Class in Selenium WebDriver
To Achieve this, follow below mentioned steps.
  1. Open the browser.
2.    Navigate to the given URL (http://automationtalks.com/).
  1. Mouse Hover on “Selenium Tutorial” tab present in the top navigational bar.
  2. Select the Menu which you want to click on (let us consider here as – “Selenium WebDriver”.
  3. Click on the “Selenium WebDriver”.
  4. Close the browser.
First define actions class –

                        Actions act = new Actions(driver);

Then, mousehover using actions class, syntax below –

act.moveToElement(driver.findElement(“webelement_Menu_location”)).build().perform();

Now, the submenu should be visible, Then click on the submenu –

driver.findElement(“WebElement_submenu”).click();

Below is the example how can be mouse hover achieved in selenium WebDriver.

package demoPackage1;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;

public class ActionsClass {
  
  @Test
  public void TestCase() throws InterruptedException{
    
    System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    
    driver.navigate().to("http://automationtalks.com/");
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    
    Actions act = new Actions(driver);

    //Define actions class & move to webelement  (Hove mouse to webelement)
    act.moveToElement(driver.findElement(By.xpath("//span[contains(.,'Selenium Tutorial')]"))).build().perform();
    
    //After mouse hover, element form dropdown is appeared, then click on it.
    driver.findElement(By.xpath("//a[contains(.,'Selenium WebDriver')]")).click();
    
    Thread.sleep(3000);
    
    
    driver.close();
    driver.quit();
    
    

    
  }

}

Hope This Helps !!!!

Right Click (Context Click) in Selenium

Right click or Context click in selenium WebDriver using Actions class-

Sometimes you’ll run into an app that has functionality hidden behind a right-click menu (a.k.a. a context menu). These menus tend to be system level menus that are untouchable by Selenium. So how do you test this functionality?

Right Click (Context Click ) using Actions Class using Selenium WebDriver
We can then select an option from the menu by traversing it with keyboard arrow keys (which we can issue with the Action Builder’s send_keys command).
In Selenium WebDriver to perform right click on any web element is not a complex process. All you have to do is create an instance of Action class and call the methods defined in it to perform the actions you want. Follow the below steps in order to perform right click on any web element:

Below are the Steps we have followed in the example:

    Identify the element
    Wait for the presence of Element
    Now perform Context click
    After that we need to select the required link.

Example –

package learnAboutActionsClass;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class RightClickInSelenium {
 
 public static void main(String[] args){
  
  WebDriver driver = new FirefoxDriver();
  driver.navigate().to("http://automationtalks.com/");
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  driver.manage().window().maximize();
  
  Actions act = new Actions(driver);
  act.moveToElement(driver.findElement(By.xpath("//*[@id='mbtnav']/li[3]/a"))).build().perform();
   act.contextClick(driver.findElement(By.xpath("//*[@id='mbtnav']/li[3]/ul/li[2]/a"))).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();
  //Switching between tabs using CTRL + tab keys.
    driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
    //Switch to current selected tab's content.
    driver.switchTo().defaultContent();  
 }

}

Here the method sendKeys(Keys.ARROW_DOWN) is used to select an option from the list. If you will not add this method, the right click on the web element will be performed and the option list which appears after the right click will get disappeared without selecting any option.

We can perform the right click on any web element using the Robot class too. Here you first need to move the mouse to the particular web element and then perform the required action…!!!

Actions class in Selenium WebDrivr

Perform series of actions using Actions class in selenium WebDriver?

You can build a perform series of actions using the Action and Actions classes. Just remember to close the series with the build() method. Consider the sample code below.

Perform Series of Actions Using Actions class in selenium WebDriver
package learnAboutActionsClass;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class PerformSeriesOfActions {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  
  WebDriver driver = new FirefoxDriver();
  
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  driver.manage().window().maximize();
  
  driver.navigate().to("https://www.facebook.com/");
  
  WebElement element = driver.findElement(By.xpath("//*[@id='email']"));
  
  Actions act = new Actions(driver);
  //Below line sends some text to field by converting it to uppercase, then double click the text so that it will select all, then do right click
  act.moveToElement(element).click().keyDown(element, Keys.SHIFT).sendKeys("panarkhede").keyUp(element, Keys.SHIFT).doubleClick(element).contextClick(element).build().perform();
  driver.quit();
 }

}
Observe below screen shot to see the series of actions performed by using above code –
Firstly, Clicked on text box.
then, sent text to text box by converting it to upper case.
then double clicked on the entered test, so that text is selected.
then right clicked on the text.

Hope This Helps !!!

How to use tab key (button) in selenium WebDriver?

There are multiple ways to perform Tab key functionality. Using Actions Class, Using SendKeys() method & few other. Let us talk about them one by one.

TAB Key using Actions Class in Selenium WebDriver

1. Using function sendKeys(Keys.Tab).

    WebElement inputField = driver.findElement(By.Locator("LocatorValue"));
    inputField.sendKeys(Keys.TAB);

2. If you are using Java then you can use Java ROBOT class to perform keyboard actions.

Robot robot = new Robot();
// Simulate key Events
robot.keyPress(keyEvent.VK_TAB);
robot.keyRelease(keyEvent.VK_TAB);

3. You can use Ascii value in send key function like sendKeys(//0061); I am not sure the ASCII value of Tag it’s just an example.

4. Using Actions class. –

Basically, you need to have instance of Actions class and then call sendKeys with TAB as TAB key.
package learnAboutActionsClass;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class TabKeyUsingActionsClass {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  
WebDriver driver = new FirefoxDriver();
  
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  driver.manage().window().maximize();
  
  driver.navigate().to("http://automationtalks.com/");
  
  WebElement element = driver.findElement(By.xpath("//input[@class='search']"));
  element.sendKeys("text to be searched");
   
   Actions act = new Actions(driver);
   
   act.sendKeys(Keys.TAB).build().perform();
   act.sendKeys(Keys.RETURN).build().perform();
   
 }

}

Hope This Helps !!!!

How to send text in capital letters into a text-box using Actions class in Selenium WebDriver?

We can send the text in capital letters (Upper case) in to a text box by using actions class of the selenium. Very simple.  First press the SHIFT key and then send the text which you want to convert to capital letter before sending to text box.
Send Capital letters to textbox using actions class in Selenium WebDriver
Below program illustrates the same –
package learnAboutActionsClass;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class SendTextInCapitalLetter {

 public static void main(String[] args) {
  // TODO Auto-generated method stub

  WebDriver driver = new FirefoxDriver();

  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  driver.manage().window().maximize();

  driver.navigate().to("http://automationtalks.com");

  String TextToBeConvertAndSendInUpperCase = "Synchronization in Selenium";

  WebElement element = driver.findElement(By.xpath("//input[@class='search']"));

  Actions act = new Actions(driver);

  act.keyDown(element, Keys.SHIFT).sendKeys(TextToBeConvertAndSendInUpperCase).keyDown(element, Keys.SHIFT).build().perform();

 }

}
Original Text was:  “Synchronization in Selenium”;
The text sent to the text box –
Hope this helps !!! post your questions if any.

How to refresh webpage using Action class in selenium WebDriver?

Refresh webpage using Actions Class in Selenium WebDriver –
There are various ways to refresh webpage in selenium webdriver. One of them using Actions class.
Refresh WebPage using Actions class in Selenium WebDriver
Application can be refreshed in multiple ways. We can use

driver.navigate().refresh();
Method, or can send key F5.
Here, Web Page refresh can be achieved by using Actions class of the selenium WebDriver.
Below program explain this –
package learnAboutActionsClass;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class RefreshUsingActionsClass {

 public static void main(String[] args) throws InterruptedException {
  // TODO Auto-generated method stub
  
  WebDriver driver = new FirefoxDriver();
  
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  driver.manage().window().maximize();
  
  driver.navigate().to("https://learnaboutsoftwaretesting.blogspot.in");
  
  //sleep the website for 4 seconds so that we can notice the refresh of web page
  Thread.sleep(4000);
  
  Actions act = new Actions(driver);
  
  //using below command we can refresh the webpage
  act.keyDown(Keys.CONTROL).sendKeys(Keys.F5).build().perform();
 }

}  

How to get Total Number of Rows and Columns in the Web table using Selenium WebDriver?

In this article i will talk about how to get Total Number of Rows and Columns in the Web table using Selenium WebDriver? Firstly let us get the basic understanding about web table.

Refer below post –

How to handle Dynamic Web Table using selenium Webdriver?

In above blog post, we learned how to get all data from web table. Now, let us see, how can we get the total number of rows and total number of columns in the web table.

Below is the HTML code for sample table.

Observe above HTML code for sample table. We know that, tagname <tr> is to indicate that, it is a row in the web table.

Tagname <tr> will be under tagname <tbody>

So, we need to get WebElement of <tbody> tag, so that we can get the count of <tr> tags & ultimately total number of rows in the web table.

So, Below is the sample code, with which we can get total number of rows in the web table.

WebElement TogetRows = driver.findElement(By.xpath("//table[@id='users_table']/tbody"));
List<WebElement>TotalRowsList = TogetRows.findElements(By.tagName("tr"));
System.out.println("Total number of Rows in the table are : "+ TotalRowsList.size());
In order to get total number of columns in the web table, what we need to do is, count total number of <td> tags in first <tr> tagname.

Below is the sample code, with which we can get total number of columns easily.

WebElement ToGetColumns = driver.findElement(By.xpath("//table[@id='users_table']/tbody/tr"));

List<WebElement> TotalColsList = ToGetColumns.findElements(By.tagName("td"));

System.out.println("Total Number of Columns in the table are: "+TotalColsList.size());
Hope this helps !!!

How to handle Dynamic Web Table using selenium Webdriver?

In this article, let us talk about how to handle dynamic web table using selenium webdriver. Before start, let us understand what is web table?
There are two types of Web Tables –
            1.       Static Web Table -> where the data is constant on the web page.
            2.       Dynamic Web table -> where the data changes dynamically based on the users request.

In a very simple language, Web table is nothing but the table present on the web page.

Now, since it is a table, it must have rows, columns, cell data, as like how we have in excel sheet.

So, when we deal with web table through selenium Webdriver, we must understand the internal table structure (how the table is created in HTML format?)

This is not very complex to understand. There are few HTML tag which defines the table.

Observe below screen shot. It is a dynamic web table.

If we see the HTML layout for this table, it is as below –

In above HTML structure, we can clearly see that, table has HTML tags like, table, thead, tbody, tr, td etc. Here –

table -> indicate that, it is a web table

thead -> includes the header of the table
tbody -> includes the body of the table.
tr -> indicate that, this is a row of the table.
td -> indicate that, this is the actual table data (as like cell data in excel).

So, this means, actual data of the web table is present under <td> tag. If you want to read this data from web table, then you should read data from <td> tag.

Let us see how can we do this.

Step1: Locate the WebElement where table is.

WebElement is nothing but HTML element, like dropdown, radio button, table, textbox etc. So, in order to get data from webtable, your first task is, to get the webElement of the table.Ex –

WebElement element1  = driver.findElement(By.xpath("//table[@id='users_table']"));

Step2: To get the list of table data

As we saw earlier, table data will be containted within tag <td>.
So, in order to get table data in to the list, we need to find all the elements by tagname <td> on your webelement.

Ex –

List<WebElement> l = element1.findElements(By.tagName("td"));


Step3: Get the data from List

Once you get data in to the List, by using above step, now we need to retrieve the data from list based on index. Here it is –

 for (int i = 0; i<l.size(); i++){
System.out.println("Total elements present in table are: " +l.size());
 System.out.println("table contents: "+l.get(i).getText());

                                }
Now, you can play with the data, as per demand in your test case.

On the similar basis, we can get total number of rows and total number of columns from the webtable. Explained in below post –