Tuesday, August 14, 2018

Questions Asked in Interview for Manual Testing Engineer?


1. What is Boundary Value Analysis and Equivalence Partitioning ?

2. What is Responsive web design ?

3. What is Globalization Testing and Localization Testing ?

4. What is System Testing and how it is different from Regression Testing ?

5. What is Smoke & Sanity Testing?

6. What is Static Testing & Dynamic Testing ?

Monday, May 14, 2018

5 Famous Puzzles asked in QA Interviews

Puzzles asked in QA Interviews

1. How to cut a cake into 8 almost equal slices in three attempts?

2. You have two ropes and a lighter. Each rope has the following property: If you light one end of the rope, it will take one hour to burn to the other end. They don't necessarily burn at a uniform rate. How can you measure a period of 45 minutes?

3. There are 5 lanes on a race track. One needs to find out the 3 fastest horses among total of 25 horses. Find out the minimum number of races to be conducted in order to determine the fastest three

4. You pull out 2 balls, one after another, from a bag which has 20 blue and 13 red balls in total. If the balls are of similar colour, then the balls are replaced with a blue ball, however, if the balls are of different colours, then a red ball is used to replace them. Once the balls are taken out of the bag, they are not placed back in the bag, and thus the number of balls keep reducing. Determine the colour of last ball left in the bag.

5. There are 2 jugs with 4 ltrs and 5 ltrs of water respectively. The objective is to pour exactly 7 ltrs of water in a bucket. How it can be achieved?

Sunday, May 13, 2018

Questions Asked in Interview for Automation Testing Engineer?

Questions Asked in Interview for Automation Testing Engineer?

1. Difference between Throws and throw keyword.

2. How to get and verify the color of dropdown text with Selenium WebDriver.

3. What is Git Life Cycle ?

4. How to click on webelement present in Web Table cell ?

5. Difference between FindByElement and FindByElements ?

6. What is the difference between HashSet and HashMap ?

7. Write a program to verify Prime Number in java?

8. Write a program to print Prime Number between 50 to 100?

9. Write a program to print reverse of string?

10. Write a program to print duplicate number in an Array?

11. Write a program to remove duplicate characters from a String?

12. Write a program to calculate sum of number?

13. Write a program to check palindrome number?

14. Write a program to import data from excel sheet with TestNG @dataProvider? ( by using Apache poi).

15. How to generate Extent Report in TestNG?

16. How to execute only failed test cases with the help of TestNG Listeners - RetryAnalyzer?

17. What is the difference between Interface and Abstract Class ?

18. What is final keyword and Finally block? 

How to verify that Image has been loaded successfully or not with Selenium WebDriver?

How to verify that Image has been loaded successfully or not with Selenium WebDriver?

Solution:-

Today, i will share the way how we can verify that Image has been loaded successfully or not with Selenium WebDriver.

Here, class name is "Testing".

Lets first create the instance of WebDriver :

WebDriver driver;
System.setProperty("webdriver.chrome.driver", "C:/Users/User/Downloads/chromedriver/chromedriver.exe");
driver = new ChromeDriver();
Open the Webpage:
driver.get("http://www.seleniumstack.in/p/images.html");
Next, create a function "checkImageLoaded" to verify Image Load


public void checkImageLoaded(WebElement images) throws Exception{
 
HttpClient client = HttpClientBuilder.create().build();
 
HttpGet request = new HttpGet(images.getAttribute("src"));
 
HttpResponse response = client.execute(request);
  
 
if(response.getStatusLine().getStatusCode()!=200){
  
      System.out.println(images.getAttribute("alt"));

 }
}
Now, create the List of Image Elements of WebPage in main method and call "checkImageLoaded" function.

public static void main(String[] args) throws InterruptedException {

  Testing test = new Testing();
  
    WebDriver driver;

    System.setProperty("webdriver.chrome.driver", "C:/Users/User/Downloads/chromedriver/chromedriver.exe");

    driver = new ChromeDriver();
  
  List images = driver.findElements(By.tagName("img"));
  
  try {
   for(WebElement ImageElement : images){
   if(ImageElement!=null){
   test.checkImageLoaded(ImageElement);
    }
   }
  } catch (Exception e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }
That's all. Hope this helps you.

Thanks

Friday, April 27, 2018

How to click on hidden element with Selenium WebDriver ?

How to click on hidden element with Selenium WebDriver ?

Solution :

It is very hot question asked in the Automation Interview.

Here, I will show you how you can click on Hidden Element with Selenium & Javascript.

For interacting with Hidden Elements we need to use "JavascriptExecutor" Interface.


Now, I need to perform click operation on the button which is disabled in DOM by using style=”display: none;”

Lets first create the instance of WebDriver :

WebDriver driver;
System.setProperty("webdriver.chrome.driver", "C:/Users/User/Downloads/chromedriver/chromedriver.exe");
driver = new ChromeDriver();
Next, we will open the url and find the WebElement i.e Button.

driver.get("file:///C:/Users/User/Desktop/Blog/Hidden.html");
WebElement btn = driver.findElement(By.cssSelector("button[id='myButton']"));
Here, we will create the object of "JavascriptExecutor" Interface and cast our WebDriver to "JavascriptExecutor".

After that we will use executeScript Method of JavascriptExecutor which will perform our task i.e "Click on hidden button".

JavascriptExecutor jsExecutor = (JavascriptExecutor)driver;
jsExecutor.executeScript("arguments[0].click();", btn);
Hope this will help you. Please share your views in Comment section below.

Thanks a lot.

How to get the color code of dropdown text with Selenium WebDriver ?

How to get the color code of dropdown text with Selenium WebDriver ?

Solution :

Lets first create the instance of WebDriver :

WebDriver driver;
System.setProperty("webdriver.chrome.driver", "C:/Users/User/Downloads/chromedriver/chromedriver.exe");
driver = new ChromeDriver();


Next, we will open the url and find the WebElement i.e dropdown.

driver.get("file:///C:/Users/User/Desktop/Blog/ColorText.html");
WebElement dropDown = driver.findElement(By.cssSelector("select[class='selectDiv']"));
Now, create the instance of "Select" class and click on the option "Audi" from dropdown
by using "selectByVisibleText()" method.

Select select = new Select(dropDown);
select.selectByVisibleText("Audi");
Now, we will get the selected option color code and by using "Color" class of java we will convert the rgb color code to hex color code.

String colorValue = select.getFirstSelectedOption().getCssValue("color");
String hexColorCode = Color.fromString(colorValue).asHex();
System.out.println("Selected Option color code is " + hexColorCode );
Hope you like this post. Thanks

How to handle a Web Table with Selenium Web Driver?

How to handle a Web Table with Selenium Web Driver?


Solution:

Web Table : A table is collection of rows and columns, table created on web is known as Web Table.
The <table> tag defines the HTML table where we use the <tr> tag for rows , the <td> tag for columns and the element defines a table header.

There are two types of Web Table :

a). Static Table :  A table where number of rows and number of columns are fixed. E.g :- Days of week table.

b). Dynamic Table : A table where number of rows and number of columns are dynamic means it may vary as per data. E.g:- Match Score Card and Organisational Sales Chart.

We will learn the following things now:

1). How to print all the data from table?
2). How to print data of specific column ?
3). How to print data of specific row?
4). How to print data of specific cell based data of another cell?
5.) How to find & print sum of all of values of column?.
6.) How to find the shares whose Current Price is less than Rs. 800?

Let Say we have a following table.
CompanyGroupPrev Close (Rs)Current Price (Rs)% Change
L&T Infotech A 1,539.15 1,716.85 + 11.55
Indiabulls Ventures A 428.70 470.40 + 9.73
NIIT Technologies A 998.55 1,080.90 + 8.25
Raymond Ltd A 1,065.50 1,132.35 + 6.27
Persistent Systems A 725.85 770.00 + 6.08
L&T Technology Serv A 1,221.35 1,289.80 + 5.60
Religare Enterprises A 56.15 58.95 + 4.99
Indiabulls Real Estate A 196.80 204.90 + 4.12
Dewan Housing A 585.10 608.55 + 4.01

First, How to print all the data from table in console ? 
Solution:-
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "C:/Users/User/Downloads/chromedriver/chromedriver.exe");
driver = new ChromeDriver();

//Open URL
driver.get("any**webtable**url");

// Now locate the tables rows and create List of webelements
List tableRows=driver.findElements(By.xpath("//*[@id='leftcontainer']/table/tbody/tr"));
  int rowSize = rows.size();
  
  for(int i=0;i<rowSize;i++){
   
   List<WebElement> cells = driver.findElements(By.xpath("//table[@class='dataTable']/tbody/tr["+i+"]/td"));
   int cellSize = cells.size();
   for(int j=0;j<cellSize;j++){
    System.out.println(cells.get(j).getText());
   }
  }
Second, How to print data of specific column ?
 List<WebElement> cell= driver.findElements(By.xpath("//table[@class='dataTable']/tbody/tr/td[3]"));
         int cellSize = cell.size();
          for(int i=0;i < cellsize; i++){
            System.out.println(cell.getText());
               }
Third, How to print data of specific row? ?
 List<WebElement> row= driver.findElements(By.xpath("//table[@class='dataTable']/tbody/tr[3]"));
         int rowSize = row.size();
          for(int i=0;i < rowSize; i++){
            System.out.println(row.getText());
               }
Fourth, How to print data of specific cell based data of another cell?
List<WebElement> rowList = driver.findElements(By.xpath("//*[@id='leftcontainer']/table/tbody/tr"));
   for(int i = 0;i < rowList.size();i++){

            String rowText = rowList.get(i).getText();

//Now, we will check if String contains value "NIIT", then we will find its Current Price  
     if(rowText.contains("NIIT")){

      List<WebElement> list = driver.findElements(By.xpath("//*[@id='leftcontainer']/table/tbody/tr/td[3]"));

      String cellText=list.get(i).getText();

      System.out.println(cellText);

   }
}
Fifth, How to find & print sum of all of values of column?.
                
List<WebElement> currentPrice = driver.findElements(By.xpath("//table[@class='dataTable']/tbody/tr/td[3]"));

  double sum = 0;

  for(int i=0;i < currentPrice.size();i++){

   sum = sum + Double.parseDouble(currentPrice.get(i).getText().replace(",", ""));

  }
  System.out.println("Total Value of all shares current price is : " + sum);

Sixth, How to find the shares price whose Current Price is less than Rs. 800?
                
List<WebElement> currentPrice = driver.findElements(By.xpath("//table[@class='dataTable']/tbody/tr/td[3]"));


  for(int i=0;i < currentPrice.size();i++){

  String refineValue = currentPrice.get(i).getText().replace(",", "");

   if(Double.parseDouble(refineValue) < = 800.00){
    System.out.println("Share Price is : " + refineValue);
   }

  }

Questions Asked in Interview for Manual Testing Engineer?

1. What is Boundary Value Analysis and Equivalence Partitioning ? 2. What is Responsive web design ? 3. What is Globalization Te...