Automation Testing

How to obtain the page title using Selenium webdriver?

We can obtain the page title using Selenium webdriver. The method getTitle() is used to obtain the present page title and then we can get the result in the console.

Syntax

t = driver.getTitle();

Let us find the title of the current page

package RK1.Building_a_selenium_project;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class PageTitle {
	
	public static WebDriver wd;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.setProperty("webdriver.chrome.driver", "F:\\Work Environment\\MyProject\\chromedriver.exe");
		wd = new ChromeDriver();
		
		
		
		//application launch
	    wd.get("https://www.testingbuddy.co.in/");
	    wd.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	    wd.manage().window().maximize();
	    
	    // getTitle() to obtain page title
	    String title = wd.getTitle();
	    
	    System.out.println(wd.getTitle());
	    System.out.println(wd.getCurrentUrl());
		
	    wd.quit();
		
		
		

	}

}
Automation Testing

How to obtain the tagname of the parent element…

We can obtain the tagname of the parent element in Selenium webdriver. First of all, we need to identify the child element with help of any of the locators like id, class, name, xpath, or CSS. Then we have to identify the parent with the findElement(By.xpath()) method.

We can identify the parent from the child, by localizing it with the child and then passing (parent::*) as a parameter to the findElement(By.xpath()). Next, to get the tagname of the parent, we have to use the getTagName() method.

Syntax

child.findElement(By.xpath("parent::*"));

Let us identify tagname of the parent of child element li in the below html code −

The tagname of the parent should be ul.

Example

Code Implementation.

package RK1.Building_a_selenium_project;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class ParentTagName {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.setProperty("webdriver.chrome.driver", "F:\\Work Environment\\MyProject\\chromedriver.exe");
		WebDriver wd = new ChromeDriver();
		
		String url = "https://www.tutorialspoint.com/about/about_careers.htm";
		
		wd.get(url);
		wd.manage().window().maximize();
		wd.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
		// identify element
	      WebElement p=wd.findElement(By.xpath("//li[@class='heading']"));

	      //identify parent from child element
	      WebElement t= p.findElement(By.xpath("parent::*"));

	      //getTagName() to get parent element tag
	      System.out.println("Parent tagname: " + t.getTagName());
	      wd.close();

	}

}

Output

Starting ChromeDriver 104.0.5112.79 (3cf3e8c8a07d104b9e1260c910efb8f383285dc5-refs/branch-heads/5112@{#1307}) on port 16278
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Aug 19, 2022 3:05:02 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Parent tagname: ul
Automation Testing

How to scroll up/down a page using Actions class…

We can perform scroll up/down a page using Actions class in Selenium webdriver. First of all, we have to create an object of this Actions class and then apply the sendKeys method on it.

Now, to scroll down a page, we have to pass the parameter Keys.PAGE_DOWN to this method. To again scroll up a page, we have to pass the parameter Keys.PAGE_UP to the sendKeys method. Finally, we have to use the build and perform methods to actually perform this action.

Syntax

Actions a = new Actions(driver);
//scroll down a page
a.sendKeys(Keys.PAGE_DOWN).build().perform();
//scroll up a page
a.sendKeys(Keys.PAGE_UP).build().perform();
package RK1.Building_a_selenium_project;

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.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

public class ScrollUpDownAction {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.setProperty("webdriver.chrome.driver", "F:\\Work Environment\\MyProject\\chromedriver.exe");
		WebDriver wd = new ChromeDriver();
		
		String url = "https://www.tutorialspoint.com/index.htm";
		
		wd.get(url);
		wd.manage().window().maximize();
		wd.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
		// object of Actions class to scroll up and down
	      Actions at = new Actions(wd);
	      at.sendKeys(Keys.PAGE_DOWN).build().perform();
	      //identify element on scroll down
	      WebElement l = wd.findElement(By.linkText("Careers"));
	      String strn = l.getText();
	      System.out.println("Text obtained by scrolling down is :"+strn);

	      at.sendKeys(Keys.PAGE_UP).build().perform();
	      //identify element on scroll up
	      WebElement m = wd.findElement(By.tagName("h1"));
	      String s = m.getText();
	      System.out.println("Text obtained by scrolling up is :"+s);
	      wd.quit();
		

	}

}
Automation Testing

How to automate drag & drop functionality using Selenium…

The drag and drop action is done with the help of a mouse. It happens when we drag and then place an element from one place to another. This is a common scenario when we try to move a file from one folder to another by simply drag and drop action.

Selenium uses the Actions class to perform the drag drop action. The dragAndDrop(source, destination) is a method under Actions class to do drag and drop operation. The method will first do a left click on the element, then continue the click to hold the source element. Next it shall move to the destination location and release the mouse.

Our aim to drag and drop the first box to the second box.

Example

Code Implementation.

package RK1.Building_a_selenium_project;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

public class DragandDrop {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.setProperty("webdriver.chrome.driver", "F:\\Work Environment\\MyProject\\chromedriver.exe");
		WebDriver wd = new ChromeDriver();
		
		String url = "https://jqueryui.com/droppable/";
		
		wd.get(url);
		wd.manage().window().maximize();
		wd.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
	    wd.switchTo().frame(0);
	      // identify source and target element
	      WebElement s=wd.findElement(By.id("draggable"));
	      WebElement t=wd.findElement(By.id("droppable"));
	      //Actions class with dragAndDrop()
	      Actions act = new Actions(wd);
	      act.dragAndDrop(s, t).build().perform();
	      wd.quit();
	      
	      

	}

}
Automation Testing

TestNG Interview Questions

TestNG Interview Questions

A list of top frequently asked TestNG Interview Questions and answers are given below.

1) What is TestNG?

TestNG stands for “Testing Next Generation“. It is an` automation testing framework used for java programming language developed by Credric beust, and it comes after the inspiration from the JUnit framework. TestNG consists of all the features of JUnit framework but also contains some more additional features that make TestNG more powerful.


2) What are the advantages of TestNG?

The following are the advantages of TestNG are:

  • It generates the report in a proper format, which includes the following information:
    • Number of test cases executed.
    • Number of test cases passed.
    • Number of test cases failed.
    • Number of test cases skipped
  • Multiple test cases can be grouped easily by converting them into a testng.xml file, in which you can set the priority of each test case that determines which test case should be executed first.
  • With the help of TestNG, you can execute the multiple test cases on multiple browsers known as cross-browser testing.
  • The TestNG framework can be easily integrated with other tools such as Maven. Jenkins, etc.
  • Annotations used in a TestNG framework are easily understandable such as @BeforeMethod, @AfterMethod, @BeforeTest, @AfterTest.
  • WebDriver does not generate the reports while TestNG generates the reports in a readable format.
  • TestNG simplifies the way the test cases are coded. We do not have to write the static main method. The sequence of actions is maintained by the annotations only.
  • TestNG allows you to execute the test cases separately. For example, if you have six test cases, then one method is written for each test case. When we run the program, five methods are executed successfully, and the sixth method is failed. To remove the error, we need to run only the sixth method, and this can be possible only through TestNG. Because TestNG generates testng-failed.xml file in the test output folder, we will run only this xml file to execute the failed test case.

3) How to run the test script in TestNG?

You can run the test script in TestNG by clicking right click on the TestNG class, click on “Run As” and then select “TestNG test”.


4) What are the annotations used in the TestNG?

The following are the annotations used in the TestNG are:

  • Precondition annotations
    Precondition annotations are executed before the execution of test methods The Precondition annotations are @BeforeSuite, @BeforeClass, @BeforeTest, @BeforeMethod.
  • Test annotation
    Test annotation is specified before the definition of the test method. It is specified as @Test.
  • Postcondition annotations
    The postcondition annotations are executed after the execution of all the test methods. The postcondition annotation can be @AfterSuite, @AfterClass, @AfterTest, @AfterMethod.

5) What is the sequence of execution of all the annotations in TestNG?

The sequence of execution of all the annotations in TestNG is given below:

  • @BeforeSuite
  • @BeforeTest
  • @BeforeClass
  • @BeforeMethod
  • @Test
  • @AfterSuite
  • @AfterTest
  • @AfterClass
  • @AfterMethod

6) How to set the priorities in TestNG?

If we do not prioritize the test methods, then the test methods are selected alphabetically and executed. If we want the test methods to be executed in the sequence we want, then we need to provide the priority along with the @Test annotation.

Let’s understand through an example.

  1. package com.javatpoint;  
  2. import org.testng.annotations.Test;  
  3. public class Test_methods   
  4. {  
  5. @Test(priority=2)  
  6. public void test1()  
  7. {  
  8. System.out.println(“Test1”);  
  9. }  
  10. @Test(priority=1)  
  11. public void test2()  
  12. {  
  13. System.out.print(“Test2”);  
  14. }  
  15. }  

7) Define grouping in TestNG?

The group is an attribute in TestNG that allows you to execute the multiple test cases. For example, if we have 100 test cases of it_department and 10 test cases of hr_department, and if you want to run all the test cases of it_department together in a single suite, this can be possible only through the grouping.

Let’s understand through an example.

  1. package com.javatpoint;  
  2. import org.testng.annotations.Test;  
  3. public class Test_methods   
  4. {  
  5. @Test(groups=”it_department”)  
  6. public void java()  
  7. {  
  8. System.out.println(“I am a java developer”);  
  9. }  
  10. @Test(groups=”it_department”)  
  11. public void dot_net()  
  12. {  
  13. System.out.println(“I am a .Net developer”);  
  14. }  
  15. @Test(groups=”it_department”)  
  16. public void tester()  
  17. {  
  18. System.out.println(“I am a software tester”);  
  19. }  
  20. @Test (groups=”hr”)  
  21. public void hr()  
  22. {  
  23. System.out.print(“I am hr”);  
  24. }  
  25. }  

testng.xml

  1. ?xml version=”1.0″ encoding=”UTF-8″?>  
  2. <!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”>  
  3. <suite name=”Suite”>  
  4. <test name=”It Company”>  
  5. <groups>  
  6. <run>  
  7. <include name=”it_department”/>  
  8. </run>  
  9. </groups>  
  10. <classes>  
  11. <class name=”com.javatpoint.Test_methods”></class>  
  12. </classes>  
  13. </test>  
  14. </suite> <!– Suite –>  

8) What is dependency in TestNG?

When we want to run the test cases in a specific order, then we use the concept of dependency in TestNG.

Two types of dependency attributes used in TestNG:

  • dependsOnMethods
    The dependsOnMethods attribute tells the TestNG on which methods this test will be dependent on, so that those methods will be executed before this test method.

  1. package com.javatpoint;  
  2. import org.testng.annotations.Test;  
  3. public class Login   
  4. {  
  5.  @Test  
  6.  public void login()  
  7.  {  
  8.      System.out.println(“Login page”);  
  9.  }  
  10.  @Test(dependsOnMethods=”login”)  
  11.  public void home()  
  12.  {  
  13.      System.out.println(“Home page”);  
  14.        
  15.  }  
  16. }  
  • dependsOnGroups
    It is similar to the dependsOnMethods attribute. It allows the test methods to depend on the group of test methods. It executes the group of test methods before the dependent test method.

  1. package com.javatpoint;  
  2. import org.testng.annotations.Test;  
  3. public class Test_cases  
  4. {  
  5.  @Test(groups=”test”)  
  6.  public void testcase1()  
  7.  {  
  8.      System.out.println(“testcase1”);  
  9.  }  
  10.  @Test(groups=”test”)  
  11.  public void testcase2()  
  12.  {  
  13.      System.out.println(“testcase2”);  
  14.  }  
  15.  @Test(dependsOnGroups=”test”)  
  16.  public void testcase3()  
  17.  {  
  18.      System.out.println(“testcase3”);  
  19.  }  
  20. }  

9) What is timeOut in TestNG?

While running test cases, there can be a case when some test cases take much more time than expected. In such a case, we can mark the test case as a failed test case by using timeOut.

TimeOut in TestNG allows you to configure the time period to wait for a test to get completely executed. It can be configured in two levels:

  • At the suit level: It will be available to all the test methods.
  • At each method level: It will be available to a particular test method.

The timeOut attribute can be specified as shown below:

  1. @Test( timeOut = 700)  

The above @Test annotation tells that the test method will be given 700 ms to complete its execution otherwise it will be marked as a failed test case.


10) What is invocationCount in TestNG?

An invocationCount in TestNG is the number of times that we want to execute the same test.

  1. package com.javatpoint;  
  2. import org.testng.annotations.Test;  
  3. public class Test_cases  
  4. {  
  5.  @Test(invocationCount=5)  
  6.  public void testcase1()  
  7.  {  
  8.      System.out.println(“testcase1”);  
  9.  }  
  10.   
  11. }  

Output

TestNG Interview Questions

11) What is the importance of testng.xml file?

The testng.xml file is important because of the following reasons:

  • It defines the order of the execution of all the test cases.
  • It allows you to group the test cases and can be executed as per the requirements.
  • It executes the selected test cases.
  • In TestNG, listeners can be implemented at the suite level.
  • It allows you to integrate the TestNG framework with tools such as Jenkins.

12) How to pass the parameter in test case through testng.xml file?

We can also pass the value to test methods at runtime, we can achieve this by sending parameter values through the testng.xml file. We can use the @Parameter annotation:

  1. @Parameter(“param-name”);  

Let’s understand through an example:

  1. package com.javatpoint;  
  2. import org.openqa.selenium.By;  
  3. import org.openqa.selenium.WebDriver;  
  4. import org.openqa.selenium.chrome.ChromeDriver;  
  5. import org.testng.annotations.Test;  
  6. import org.testng.annotations.Parameters;  
  7. public class Web {  
  8. @Parameters({“text”})  
  9. @Test  
  10. public void search()  
  11. {  
  12. // TODO Auto-generated method stub  
  13. System.setProperty(“webdriver.chrome.driver”, “D:\\chromedriver.exe”);  
  14. WebDriver driver=new ChromeDriver();  
  15. driver.get(“http://www.google.com/”);  
  16. driver.findElement(By.name(“q”)).sendKeys(“javatpoint tutorial”);  
  17. }  
  18. }  

testng.xml file

  1. <?xml version=”1.0″ encoding=”UTF-8″?>  
  2. <!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”>  
  3. <suite name=”Suite”>  
  4. <test name=”It Company”>  
  5. <parameter name=”text” value=”javatpoint”/>  
  6. <classes>  
  7. <class name=”com.javatpoint.Web”></class>  
  8. </classes>  
  9. </test>  
  10. </suite> <!– Suite –>  

On running the testng.xml file, we get the output as shown below:

TestNG Interview Questions
TestNG Interview Questions

13) How can we disable the test case from running?

We can disable the test case from running by using the enabled attribute. We can assign the false value to the enabled attribute, in this way we can disable the test case from running.

  1. package com.javatpoint;  
  2. import org.testng.annotations.Test;  
  3. public class Test_cases  
  4. {  
  5.  @Test(enabled=false)  
  6.  public void testcase1()  
  7.  {  
  8.      System.out.println(“testcase1”);  
  9.  }  
  10.  @Test   
  11.  public void testcase2()  
  12.  {  
  13.      System.out.println(“testcase2”);  
  14.  }  
  15.   
  16. }  

14) What is the difference between soft assertion and hard assertion?

Soft Assertion: In case of Soft Assertion, if TestNG gets an error during @Test, it will throw an exception when an assertion fails and continues with the next statement after the assert statement.

Hard Assertion: In the case of Hard Assertion, if TestNG gets an error during @Test, it will throw an AssertException immediately when an assertion fails and stops execution after the assert statement.

Let’s understand through an example.

  1. package com.javatpoint;  
  2. import org.testng.Assert;  
  3. import org.testng.annotations.Test;  
  4. import org.testng.asserts.SoftAssert;  
  5. public class Assertion {  
  6. SoftAssert soft_assert=new SoftAssert();  
  7. @Test  
  8. public void Soft_Assert()  
  9. {  
  10.  soft_assert.assertTrue(false);  
  11.  System.out.println(“soft assertion”);  
  12. }  
  13. @Test  
  14. public void Hard_Assert()  
  15. {  
  16.  Assert.assertTrue(false);  
  17.  System.out.println(“hard assertion”);  
  18. }  
  19. }  

Output

TestNG Interview Questions

15) What is the use of @Listener annotation in TestNG?

TestNG provides different kinds of listeners which can perform different actions whenever the event is triggered. The most widely used listener in TestNG is ITestListener interface. The ITestListener interface contains methods such as onTestSuccess, onTestfailure, onTestSkipped, etc.

Following are the scenarios that can be made:

  • If the test case is failed, then what action should be performed by the listener.
  • If the test case is passed, then what action should be performed by the listener.
  • If the test case is skipped, then what action should be performed by the listener.

Let’s understand through an example.

  1. package com.javatpoint;  
  2. import org.testng.Assert;  
  3. import org.testng.annotations.Listeners;  
  4. import org.testng.annotations.Test;  
  5. @Listeners(com.javatpoint.Listener.class)  
  6. public class Test_cases  
  7. {  
  8.       
  9.  @Test  
  10.  public void test_to_success()  
  11.  {  
  12.      Assert.assertTrue(true);  
  13.  }  
  14.  @Test  
  15.  public void test_to_fail()  
  16.  {  
  17.      Assert.assertTrue(false);  
  18.  }  
  19.   
  20. }  

Listener.java

  1. package com.javatpoint;  
  2. import org.testng.ITestContext;  
  3. import org.testng.ITestListener;  
  4. import org.testng.ITestResult;  
  5. public class Listener implements ITestListener   
  6. {  
  7. @Override  
  8. public void onTestStart(ITestResult result) {  
  9. // TODO Auto-generated method stub  
  10. }  
  11. @Override  
  12. public void onTestSuccess(ITestResult result) {  
  13. // TODO Auto-generated method stub  
  14. System.out.println(“Success of test cases and its details are : “+result.getName());  
  15. }  
  16. @Override  
  17. public void onTestFailure(ITestResult result) {  
  18. // TODO Auto-generated method stub  
  19. System.out.println(“Failure of test cases and its details are : “+result.getName());  
  20. }  
  21. @Override  
  22. public void onTestSkipped(ITestResult result) {  
  23. // TODO Auto-generated method stub  
  24. System.out.println(“Skip of test cases and its details are : “+result.getName());  
  25. }  
  26. @Override  
  27. public void onTestFailedButWithinSuccessPercentage(ITestResult result) {  
  28. // TODO Auto-generated method stub  
  29. System.out.println(“Failure of test cases and its details are : “+result.getName());  
  30. }  
  31. @Override  
  32. public void onStart(ITestContext context) {  
  33. // TODO Auto-generated method stub  
  34. }  
  35. @Override  
  36. public void onFinish(ITestContext context) {  
  37. // TODO Auto-generated method stub  
  38. }}  

Output

TestNG Interview Questions

16) What is the use of @Factory annotation?

The @Factory annotation is useful when we want to run multiple test cases through a single test class. It is mainly used for the dynamic execution of test cases.

Let’s understand through an example.

testcase1.java

  1. package com.javatpoint;  
  2. import org.testng.annotations.Test;  
  3. public class Testcase1  
  4. {  
  5. @Test  
  6. public void test1()  
  7. {  
  8. System.out.println(“testcase 1”);  
  9. }  
  10. }  

testcase2.java

  1. package com.javatpoint;  
  2. import org.testng.annotations.Test;  
  3. public class Testcase2   
  4. {  
  5. @Test  
  6. public void test1()  
  7. {  
  8. System.out.println(“testcase 2”);  
  9. }  
  10. }  

Factory.java

  1. import org.testng.annotations.Factory;  
  2. public class Factory1  
  3. {  
  4. @Factory  
  5. public Object[] getTestClasses()  
  6. {  
  7. Object tests[]=new Object[2];  
  8. tests[0]=new Testcase1();  
  9. tests[1]=new Testcase2();  
  10. return tests;  
  11. }  
  12. }  

17) What is the difference between @Factory and @DataProvider annotation?

@DataProvider: It is annotation used by TestNG to execute the test method multiple numbers of times based on the data provided by the DataProvider.

@Factory: It is annotation used by the TestNG to execute the test methods present in the same test class using different instances of the respective class.

Agile Methodology

Agile Interview Questions

Agile Interview Questions

Here, we are giving the most relevant Agile Scrum interview questions with answers and hope these questions will help you while preparing for the agile scrum interview.

1) What is an agile or agile methodology?

Agile is an iterative approach of software development methodology using short iterations of 1 to 4 weeks. Due to the agile methodology, the development process is aligned to deliver the changing business requirement.


2) What are some quality strategies of agile?

Some quality strategies of agile are:

  • Iteration
  • Re-factoring
  • Dynamic code analysis
  • Short feedback cycles
  • Reviews and inspection
  • Standards and guidelines
  • Milestone reviews

3) What are an agile manifesto and its principle?

Agile manifesto uncovers the better way of developing software by doing it and helping others to do it. Agile has 4 manifesto and 12 principles which defines:

4

  • Individuals and interactions, i.e., self-motivating and self-organized should be encouraged.
  • Demonstrate the working software at regular intervals with comprehensive documentation.
  • Customers are collaboration over contact negotiation.
  • Responding to change over following a plan.

The principles of agile manifesto are-

  1. Customer Satisfaction: Manifesto provides high priority to satisfy the costumer’s requirements. Customer satisfaction is done through early and continuous delivery of valuable software.
  2. Welcome Change: Making change during software development is common and inevitable. Every changing requirement should be welcome, even in the late development phase. Agile process is used to increase the customer’s competitive advantage.
  3. Deliver the Working Software: Deliver the working software frequently, ranging from a few weeks to a few months with considering the shortest period.


4) Is there any disadvantage of the agile model (SDLC)?

Disadvantages of Agile SDLC:

  1. The development team should be highly professional and client-oriented.
  2. New requirement may be a conflict with the existing architecture.
  3. With further correction and change, there may be chances that the project will cross the expected time.
  4. There may be difficult to estimate the final coast of the project due to constant iteration.
  5. A defined requirement is absent.


5) What are the burn-up and burn-down chart?

The burn-up chart depicts the amount of work done in the project, whereas the burn-down chart illustrates the amount of work remaining in the project. Thus, the burn-up and burn-down are used to describe the progress report of the project.


6) What do you understand by Daily Stand-Up?

The daily stand-up is the day-to-day meeting (mostly in the morning) in which the whole team meets around 15 minutes to find the answer for the following three questions:

  • What was done yesterday?
  • What is your plan for today?
  • Is there any obstacle that restricts you to complete your task?

7) What do you understand about Scrum?

Scrum is a framework that helps agile teams work together to develop, deliver, and sustain the complex product in the shortest time. The product provides by scrum team in this shortest period is known as a sprint.


8) What are the different roles in Scrum?

There are three different roles in scrum. These are the Scrum MasterProduct OwnerAgile Development Team:

  • Scrum Master: The Scrum Master is a team leader and facility provider who help the team member to follow agile practices so that they can meet their commitments and customers requirements.
  • Product Owner: The Product Owner is one who runs the product from a business perspective. He defines the requirements and prioritizes their values.
  • Agile Development Team: Agile development team provides the judgment on the technical feasibilities or any dependencies.

9) What are the responsibilities of the Scrum Master?

The critical responsibility of Scrum Master includes:

  • Tracking and monitoring project development.
  • Understanding the user requirement correctly.
  • Work to obtain the project properly.
  • Improving the performance of the team.
  • Organized meetings and resolve issues.
  • Communicate and report to the customer and development team.

10) What are different ceremonies and their importance in Scrum?

To clearly express the Scrum planning, Scrum review, Scrum Daily stand up, and scrum retrospective is the purpose of the ceremony. The importance of these ceremonies is to use sprint as per your project.


11) What do you know about Scrum ban?

Scrum-ban is a Scrum and Kanban-based model for software development. This model is used in the project that needs continuous maintenance, various programming error, or some sudden changes.


12) What do you understand by the term agile testing?

The agile testing is the software testing process which is fully based on the principle of agile software development. It is the iterative approach where the user story becomes the output of the collaboration between the product owner and the development team.


13) What are the major principles of agile testing?

Some of the essential principles of agile testing are:

  • Customer satisfaction
  • Face to face communication
  • Sustainable development
  • Continuous feedback
  • Quick respond to changes
  • Successive improvement
  • Self-organized
  • Focus on essence
  • Error-free clean node
  • Collective work

14) What are the skills of a good agile tester?

The agile tester is one who implements the principle of agile software development principles for software testing. An excellent agile tester has the following skills:

  • He must be familiar with the principles and concept of agile.
  • He must be excellent communication skill to communicate with the team and the clients.
  • He can set the priority of a task according to customer requirements.
  • He should able to understand the customer requirement properly.
  • He should understand the project risk due to changing demand.

15) Name the agile frameworks.

Some of the agile frameworks are:

  • Scrum
  • Kanban
  • Feature Driven Development
  • Test Driven Development

16) Is it ever suggested to use waterfall over Scrum? If yes, explain when.

Yes, sometimes we use waterfall module over scrum. This is because when the client requirement is simple, small, well-defined, fully understood, predictable, and the subject does not change until the project complete.


17) Name some methodologies and development where you have used the agile model.

While answering this type of question, keep in mind to mention those methodologies from which you are familiar whit. Some of the methodologies where agile is used are:

  • Crystal methodologies
  • Lean software development
  • Dynamic development
  • Feature-driven development

18) What was the length of sprints/iterations in your project?

It is a common question for experienced people. The idea behind is to judge in which kind of environment you have worked? There will be follow up of the question that the length fixed in the beginning and never changed? Did you try with less than this length or more than that?


19) What is the difference between the agile & traditional way of working?

The traditional way of development is that which follow the sequential where design -> development -> testing etc. is performed whereas, in agile development, all of this is done in every iteration/sprint.


20) Why does Scrum encourage the use of automated testing for projects?

Due to faster possible delivery of the project, the Scrum development encourages to use automated (automated performance or automated regression) testing. While answering this question, you should explain some tools that you have used for automated testing.

Agile Methodology

JIRA Interview Questions

JIRA Interview Questions

A list of frequently asked JIRA Interview Questions and Answers are given below.

1) What is Jira?

  • Jira is a software testing tool developed by an Australian company, i.e., Atlassian.
  • It is a bug tracking tool used to track the issues and bugs related to your software and Mobile apps.
  • The name “Jira” comes from the Japanese word “Gojira”, which means Godzilla.
  • Jira is based on Agile methodology, and the current version of Jira is 6.

2) Explain Jira workflow.

Jira workflow is a set of activities performed to track and transition of an issue during the lifecycle of an issue where transition represents the link between the two statuses when an issue moves from one status to another status, and status determines the impact of the work on an issue filed by the tester.

The following are the phases that occur in a workflow:

  • TODO
  • In Progress
  • Done

The Jira workflow is known as defect lifecycle or bug lifecycle. The bug lifecycle consists of the following phases:

Open issue
When the issue is created by the tester, then the issue is assigned to the software developer, and they start working on it.

In Progress
This is the phase where the software developers start working on the issue.

Resolved issue
When the issue is resolved by the software developer and waiting for the verification by the software tester. If the verification is successful, then the issue is closed; otherwise, the issue gets reopened.

Reopened issue
If the verification is unsuccessful, then the issue is reopened and assigned to the software developer.

Close issue
If the verification of the fixed bug is successful, then the issue is closed by the tester.


3) Explain the report types generated by Jira.

Jira is a defect tracking tool that creates different reports which allow you to get an overview of the current status of a project.

JIRA report is a pictorial representation of the current status of a project in the form of charts, line-charts, bar-graphs, etc.

The following are the reports generated by Jira:

  • Average Age report
    The average report is a bar chart that displays the average age of unresolved issues for a project or filter.
  • The Average Age report is generated that depends upon the selected project, the type of issue selected in the filter, and time is chosen (hours/days/week/months).
  • Created vs. Resolved Issues report
  • The created vs. resolved issues report displays the difference chart between the number of issues created and the number of issues resolved within a timeframe.
  • Pie chart

The pie chart is used to display the issues grouped by a specified field, and the specified field can be priority, assignee, project, issue type, etc.

  • Recently created issue report

The recently created issue report represents a chart that shows the rate at which the new issues are created and how many issues are resolved during the same interval.

  • Resolution Time Report

The resolution time report determines the length of the time taken to resolve the issues for a project/filter.

  • Single Level Group by the Report

The single-level group by the report does not display the chart, but it categorizes the issues grouped by a particular field for a filter.

  • Time Since Issue Reports

The time since the issue report is a bar chart that shows the number of issues of a particular data field which was set on a given date. Suppose I choose the “Created” as a data field then the bar chart shows the number of issues which are created.


4) Explain the process of how an issue is generated in Jira.

The following are the steps to create an issue:

  • Click on the ‘+’ button to create an issue. On clicking on the ‘+’ button, the screen appears which is shown below:
JIRA Interview Questions

Project: It determines the name of the project.
Issue Type: It is a dropdown which displays the lists of all the issue types. You can choose either of them such as Bug, epic, task, sub task.
Summary: In the summary text field, you need to type the summary related to the issue that you are creating.
Priority: You can set the priority of an issue. It can be either medium, high, low.When you fill all the details related to your issue, click on the create button.


5) What is the way with which an issue can be shared with other users in Jira.

An issue can also be shared with other users in Jira. The following are the steps required to share an issue with other users in Jira:

  • Suppose we have an issue that already exists in Jira, i.e., the login button is not working.
JIRA Interview Questions

The above screen shows that an issue “TP-2 login button is not working” has been created.

If we want to share the issue, then this can be achieved by using the share option available on the issue’s description, it can be shown in the below screenshot:

JIRA Interview Questions
  • Click on the share shown in the above screenshot. On clicking on the share, the screen appears shown below:
JIRA Interview Questions

The above screen shows that the dialog box appears on clicking on the share button, and in a dialog box, you need to enter the name, team or email address of a user to which you want to share your issue.


6) What is the purpose of Dashboard?

Once you log in to the Jira, Dashboard is the first display which you see. Jira admin can change the view of the dashboard, and also you can change the things that are visible on the dashboard.

A dashboard displays gadgets and apps that help the team members to track the project’s progress.

The dashboard contains useful information, such as the issues assigned to the logged-in user and the user’s activity stream.

On clicking on the Dashboard link appearing at the left side of the panel, the page appears which is shown below:

JIRA Interview Questions

Following are the steps required to create a Dashboard:

  • Click on the Dashboards appearing on the left side of the panel.
  • Click on the (…) button appearing at the top right corner of the page.
JIRA Interview Questions
  • Click on the Create dashboard option appearing in the dropdown menu of (…) option.
  • On clicking on the Create dashboard, the screen appears, which is shown below:
JIRA Interview Questions

Where,

Name: It provides the descriptive name of a dashboard.

Description: It is not a mandatory field. In this field, you can add the description of a dashboard that you are creating.

Start from: Start from is a field that contains the dropdown in which you can choose either Blank Dashboard (It is a blank dashboard which does not contain any gadgets, but you can customize the dashboard according to your needs) or Default dashboard (It is pre-existing dashboard).

Shared with: Select the user and group to which you want to share your Dashboard.


7) What do you mean by scheduling an issue?

We can schedule the issues due dates which are used to track, review, and inform the team about due dates. Scheduling an issue is the most powerful feature that performs the fixed and relative date searches based on the due dates.

Advanced searches can also be performed by using the Jira Query Language.

You can schedule an issue by using the Date field. It can be done either by creating a new issue or editing an issue.


8) Explain how project details are listed in Jira?

Project in Jira comes with the main attributes, and these attributes can be a Name of the project, key, components, versions.

When you log in to the Jira, the first page that appears is the Dashboard.

JIRA Interview Questions

In the above screen, the right-hand side section represents the Activity Stream that contains all the activities which you performed on an issue or a project.


9) What are the issue types that are created and tracked via JIRA?

An issue in Jira can be a bug, feature, task, or any project work. Each Jira project comes with default issue types, and these issue types depend on the type of project that you are using.

There are three types of Jira projects:

  • Jira Core (business projects)
  • Jira Software (software projects)
  • Jira Service Desk (service desk projects)

Two types of issue exist in Jira Core:

  • Task
    The task is a work that needs to be completed.
  • Subtask
    Subtask is a piece of work which needs to be done to complete a task.

Five types of issue exist in Jira Software:

  • Bug
    A bug is a problem that exists in the functionality of a product.
  • Epic
    Epic is a big user story which needs to be broken into smaller stories.
  • Subtask
    Subtask is a piece of work which needs to be done to complete a task.
  • Task
    Task is a work that needs to be completed.
  • Story
    The story is the smallest unit of work which needs to be completed.

Eight types of issue exist in Jira Service Desk:

  • Change
    It requests a change in a current IT profile.
  • IT help
    It requests for help related to an IT-related problem.
  • Incident
    It is used for reporting an incident.
  • New feature
    It requests for adding a new feature or capability in software.
  • Problem
    It is used for investigating and reporting the root cause of multiple incidents.
  • Service request
    It is requesting for help from an internal or customer service desk.
  • Service request with approval
    It is used for requesting help that requires the approval of a manager or a board.
  • Support
    It is used for requesting help for customer support related issues.

10) How is sub-task created in Jira?

The following are the steps required to create a sub-task:

Step 1: Open the issue for which you want to create the sub-task.

Step 2: Click on theJIRA Interview Questionsicon to create a sub-task.

JIRA Interview Questions

Step 3: To create a sub task, you need to enter the following screen shown in the below screen:

JIRA Interview Questions

11) Explain the term cloning an issue?

  • Cloning an issue means creating the duplicate copy of an issue within the same project. The clone issue is basically a copy of the original issue which is pertaining to the same information stored in the original issue.
  • A clone issue is a separate entity from the original issue, but it can be linked to the original issue.
  • Operations applied to the original issue will not have any effect on the clone issue

12) Explain Kanban board?

Kanban board is a tool used to visualize the work and limit work-in-progress.

As in scrum, we are taking some activities from a product backlog and adding in a sprint backlog. However, in Kanban, we do not have sprint, so sprint backlog activity will not be performed. This is the main difference between scrum and Kanban that scrum contains sprint backlog while kanban does not contain the sprint backlog.

Kanban board consists of three states:

  • To Do
  • Doing
  • Done
JIRA Interview Questions

When the project is started, then we put all the activities from the product backlog to the ‘To Do‘ state. When the team member starts working on an activity, then that activity is put in a ‘Doing‘ state, and when the activity is placed, then it is placed in a ‘Done‘ state.

From the Kanban board, one can get to know which activities have been done and which activities they need to develop.

One of the most important features of the Kanban board is a Limit option. In the above figure, we have eight tasks in a product backlog and limit set is 4. At a time, it will take only four tasks in a ‘To Do‘ state, and if any of the tasks come in a ‘Doing‘ state, then one more task from the product backlog will be placed in a ‘To Do‘ state. In this way, we can set the limit depending on the availability of the resources.


13) Explain Scrum board?

The Scrum Board is a physical board on which the user stories present in the current sprint backlog are displayed.

JIRA Interview Questions

Scrum board is divided into columns such as:

  • Stories: This column contains all the user stories available in the current sprint backlog.
  • TODO: This state contains the subtasks of the stories on which the work has not started on.
  • In Progress: This state contains all the tasks on which the work has started.
  • Done: This state contains all the tasks at which all the work have been completed.

14) List all the reports generated by Kanban projects in Jira?

The two types of reports are generated by Kanban projects:

  • Control chart

The control chart is a useful chart which helps in measuring the team’s performance. The control chart displays the average cycle time of your team over a period of time. The control chart plots the following issues on the chart:

  • Any issues which are outside the standard deviation known as outliers.
  • It displays the average time taken to complete the tasks.
  • It also displays the team’s rolling average.

It displays the average cycle time of your product, version, or a sprint.

It helps you to identify whether the data from the current sprint determines the future performance of a product, i.e., the less variance in the cycle time means that median or mean can determine the future performance.

How to create a Control flow chart

The following are the steps to create a control flow chart:

  • Go to the Jira official website.
  • Click on the project on which you are working.
  • Click on the Reports appearing at the left side of the panel.
  • Select the Control chart.
  • Cumulative flow diagram
    • Cumulative flow diagram is a kanban tool that allows the team to view the effort and project’s effort.
    • Cumulative diagram consists of two axis, i.e., X-axis and Y-axis where X-axis (horizontal axis) represents the time taken to complete a task and Y-axis (vertical axis) represents the number of issues or tasks.
    • The size of the area represents the number of work items currently involved in each state for the selected time period.
JIRA Interview Questions

Features of Cumulative flow diagram:

  • Monitor how WIP builds over time
    If the line goes up, which means that WIP (Work In Progress) goes up means that the team is working on more tasks than handling them at a time. Increase in WIP results in increased cycle times, and this reduces team efficiency. So, it is important to keep the line straight.
  • Observe how much team delivers
    With the help of CFD diagram, we can keep track of all the tasks which have been delivered by the team. If the bottom line of the CFD diagram represents the Done state, then the slope of the line between any two points would represent the average throughput between these two points.
  • Spot bottlenecks instantly
    Cumulative diagram determines the exact amount of work in each state of your project. If one or more areas represent that WIP is expanding, then CFD spots this bottleneck instantly.
  • Measure your past performance
    The horizontal difference between the top line and bottom line at any point provides the process approximate average cycle time. The comparison between the exact cycle time and approximate cycle time provides you a good understanding of the process performance.
  • Monitor your process health
    Cumulative flow diagram is used to evaluate the efficiency of a process and also helps to identify the problems to achieve a stable and healthy process. The average arrival rate must be close to the average throughput to achieve a stable system, i.e., Average Cycle Time= Average Throughput.

15) List all the reports generated by scrum projects in Jira?

The following are the reports generated by scrum projects in Jira are:

  • Burndown chart
    Burndown chart displays the amount of work that has been completed in a sprint, and the total work is remaining.
    Burndown chart is useful as it provides the following observations:
    • If the team finishes its work early, which means that the team is not committed with sufficient work during sprint planning.
    • If the team does not finish its work within a sprint means that they are committed with a lot of work.
    • If the burndown chart drops sharply which means that the work has not been estimated properly.

How to create a Burndown chart

The following are the steps required to create a Burndown chart:

  • Go the Jira official website.
  • Click on the project on which you are working.
  • Click on the Reports appearing at the left side of the panel.
  • Select the Burndown chart.
  • Burnup chart

Burnup chart is the visual representation of a sprint’s completed work compared with the total scope. It is used to identify problems such as deviation from the planned project path.

How to create a Burnup chart

The following are the steps required to create a Burnup chart:

  • Go to the Jira official website.
  • Click on the project on which you are working.
  • Click on the Reports appearing at the left side of the panel.
  • Select the Burnup chart from the Reports dropdown.

The following are the important points related to the Burnup chart:

  • The vertical axis represents the amount of work, and it can be measured in different ways such as Story points, issues count, or estimates while the horizontal axis represents the time in days.
  • The distance between the lines on a chart is the remaining amount of work. When all the issues have been completed, the lines will meet.

16) Define a component in Jira?

Components are the subdivisions of a project and used to group the issues within a project into smaller parts.


17) How to delete a component in Jira?

Follow the below steps to delete a component in Jira:

  • Click on the Components appearing at the left side of the panel.
JIRA Interview Questions
  • Click on the ‘…’ icon then the dropdown appears which shows two options, i.e., Edit and Delete.
JIRA Interview Questions
  • Click on the Delete option to delete the component from the Jira project.

18) What is a validator in Jira?

Validators check whether the input provided by the user is valid before the transition is performed.

If the validation fails, then the issue does not proceed to the destination status of the transition.

List of validators:

  • Required Field validators
    Required field validator ensures that the field is mandatory or required. The required fields marked with the red asterisk (*) on every transition screen. In Jira, we can use the field configuration to make the fields compulsory or mandatory. With the help of Required field validators, it is possible to make the fields mandatory that makes the overall process more user-friendly.
  • Regular Expression Validator
    Regular Expression Validator checks whether the input given to a certain field matches the regular expression that you define. It is a quite powerful validator, and its use cases vary from the simple validation, the user should provide the exact value that matches the use cases.

Parameters

Regular expression: It is an expression that the input field should match.

User define message: This message appears when the validation fails.

  • Validator to compare to two fields with each other
    This validator is used to compare the two fields. To use this validator, both the fields must be of the same type.
    The following is the list of operators that this validator supports:
    • > ( greater than)
    • < ( less than)
    • >= (greater than or equal to)
    • <= (less than or equal to)
    • = (equal)
    • != (Not equal)
  • Date Compare Validator
    The Date Compare Validator is used to compare the date field with the fixed date. It can support the date field types such as Date fields (Date and date with time). We can use a fixed date in the format yyyy-mm-dd hh:mm or a pattern (days, months, weeks, years).
  • Field Compare Validator
    Field Compare Validator is a validator that compares the fields against the fixed values.
    It supports the following operators:
    • = (equal to)
    • != (Not equal to)
    • > (greater than)
    • >= (greater than or equal to)
    • < (less than)
    • <= (less than or equal to)
    • IN
    • NOT IN
    • CONTAINS
    It supports the comparison types such as String, Number, and Option ID. For example, we have a field named “Salary”, and its field value should not be less than 30,000, it can be represented as:
    Salary>=30,000;
  • User in Project Role Validator
    This validator ensures that the currently logged in user should be in a certain specific role. For example, only a user with a role “Developer” can do this workflow transition.
  • User in Group Validator
    It validates that the current user should be in any of the specified groups.
  • User in Field Validator
    This validator ensures that the current logged in user is set on a certain field.
    There are two options available in this validator:
    • You can set the status of a current user in a field.
    • He/she is not set in this field.
  • Parent Issue Type Validator
    This validator is used to prevent creating the subtasks from the parent issue. We can achieve this by adding a validator to the “Create” transition from the subtask. You can also provide a custom error message for this type of validator.
  • Parent Issue Status Validator
    This validator ensures that the parent issue should have some specific status. The status can be Reopened, In Progress, Backlog, etc.
  • Field Values Changed Validator
    Field Values Changed Validator ensures that the user can change the value in a field.
  • JQL Validator
    JQL (Jira Query Language) evaluates the current issue against the JQL query. In JQL Validator, the query is generated automatically related to the issue.
    JQL Validator provides some additional fields:
    Validator message: It is used to define the custom error message if the validation fails. If you do not want to provide the custom error message, then you can leave this field as empty.
    Run as user: In this field, we can define a technical user with which the JQL expression will be evaluated. If you leave this field as empty, then the current user will be considered for this transition.

19) What is an issue collector?

An issue collector allows you to gather the feedback form of any website in the form of Jira issues. It can also collect the issues who do not have a Jira account.


20) What are the differences between Scrum board and Kanban board?

The following are the differences between Scrum board and kanban board:

ScrumKanban
PlanningIt has fixed planning. It focussed on planning. It starts with the sprint planning and ends with the sprint review, retrospective. The daily meeting is held so that the team knows the next steps, priorities, and the learnings from the previous steps.It has no fixed planning, and no daily meetings are conducted. In Kanban, changes can occur at any time, i.e., frequent changes occur.
TimelineIn scrum, we work on the sprint that has the fixed-time duration means that after some fixed-time, we are delivering something to the client.Kanban does not have the concept of a sprint, so it has no fixed timeline for delivering the product to the client.
Task estimatesDuring sprint planning, it is decided that how many activities are to be pulled from the product backlog and add in a sprint backlog. For example, if the sprint is for two weeks, then the number of activities are selected in such a way that they can be completed within the sprint, i.e., in two weeks.It does not estimate the task.
Scrum MasterIn scrum methodology, we have one scrum master who handles the team and conducts the meeting on a daily basis.In Kanban methodology, we do not have any scrum master. It’s the responsibility of each individual to deliver a valuable product.
SuitabilityThis methodology is suitable for large-sized projects as large-sized projects can be divided into multiple sprints.It is mainly suitable for small-sized projects.
Constant changesIn Scrum, constant changes can be adapted easily in shorter sprints.If any major change occurs, then Kanban methodology gets failed.
CostIn Scrum, the task is estimated, i.e., a fixed number of activities are taken in a sprint, so the total cost of the project is minimal.In Kanban, the task is not estimated, so the total cost of the project is not accurate.
Roles and responsibilitiesIn Scrum, a specific role is assigned to the team members by the Scrum Master while the product owner tells the objectives of the product on which team members have to work.No predefined role is assigned to the team members. It’s the responsibility of all the team members to work in collaboration to deliver a valuable product.
Measurement of ProductivityThe productivity is measured by using cycle time or the time taken to complete the whole project from start to the end.Productivity is measured by using velocity through sprints.
Release MethodologySmall release after the end of each sprint.It provides continuous delivery.
SQL

SQL Interview Questions and Answers

SQL Interview Questions

The following are the most popular and useful SQL interview questions and answers for fresher and experienced candidates. These questions are created specifically to familiarise you with the types of questions you might encounter during your SQL interview. According to our experiences, good interviewers rarely plan to ask any specific topic during the interview. Instead, questioning usually begins with a basic understanding of the subject, and based on your responses, further discussion happened.

1) What is SQL?

SQL stands for the Structured Query Language. It is the standard language used to maintain the relational database and perform many different data manipulation operations on the data. SQL was initially invented in 1970. It is a database language used for database creation, deletion, fetching and modifying rows, etc. sometimes, it is pronounced as ‘sequel.’ We can also use it to handle organized data comprised of entities (variables) and relations between different entities of the data.


2) When SQL appeared?

SQL first appeared in 1974. It is one of the most used languages for maintaining the relational database. In 1986, SQL became the standard of the American National Standards Institute (ANSI) and ISO (International Organization for Standardization) in 1987.


3) What are the usages of SQL?

SQL is responsible for maintaining the relational data and the data structures present in the database. Some of the common usages are given below:PauseUnmute

  • To execute queries against a database
  • To retrieve data from a database
  • To inserts records in a database
  • To updates records in a database
  • To delete records from a database
  • To create new databases
  • To create new tables in a database
  • To create views in a database
  • To perform complex operations on the database.

4) Does SQL support programming language features?

SQL refers to the Standard Query Language. Therefore, it is true that SQL is a language but does not actually support the programming language. It is a common language that doesn’t have a loop, conditional statements, and logical operations. It cannot be used for anything other than data manipulation. It is a command language to perform database operations. The primary purpose of SQL is to retrieve, manipulate, update, delete, and perform complex operations like joins on the data present in the database.


5) What are the subsets of SQL?

The following are the four significant subsets of the SQL:

  • Data definition language (DDL): It defines the data structure that consists of commands like CREATE, ALTER, DROP, etc.
  • Data manipulation language (DML): It is used to manipulate existing data in the database. The commands in this category are SELECT, UPDATE, INSERT, etc.
  • Data control language (DCL): It controls access to the data stored in the database. The commands in this category include GRANT and REVOKE.
  • Transaction Control Language (TCL): It is used to deal with the transaction operations in the database. The commands in this category are COMMIT, ROLLBACK, SET TRANSACTION, SAVEPOINT, etc.

6) What is the purpose of DDL Language?

DDL stands for Data definition language. It is the subset of a database that defines the data structure of the database when the database is created. For example, we can use the DDL commands to add, remove, or modify tables. It consists of the following commands: CREATE, ALTER and DELETE database objects such as schema, tables, indexes, view, sequence, etc.

Example

  1. CREATE TABLE Students  
  2. (  
  3. Roll_no INT,  
  4. Name VARCHAR(45),  
  5. Branch VARCHAR(30),  
  6. );  

7) What is the purpose of DML Language?

Data manipulation language makes the user able to retrieve and manipulate data in a relational database. The DML commands can only perform read-only operations on data. We can perform the following operations using DDL language:

  • Insert data into the database through the INSERT command.
  • Retrieve data from the database through the SELECT command.
  • Update data in the database through the UPDATE command.
  • Delete data from the database through the DELETE command.

Example

  1. INSERT INTO Student VALUES (111, ‘George’, ‘Computer Science’)  

8) What is the purpose of DCL Language?

Data control language allows users to control access and permission management to the database. It is the subset of a database, which decides that what part of the database should be accessed by which user at what point of time. It includes two commands, GRANT and REVOKE.

GRANT: It enables system administrators to assign privileges and roles to the specific user accounts to perform specific tasks on the database.

REVOKE: It enables system administrators to revoke privileges and roles from the user accounts so that they cannot use the previously assigned permission on the database.

Example

  1. GRANT * ON mydb.Student TO javatpoint@localhsot;  

9) What are tables and fields in the database?

A table is a set of organized data in the form of rows and columns. It enables users to store and display records in the structure format. It is similar to worksheets in the spreadsheet application. Here rows refer to the tuples, representing the simple data item, and columns are the attribute of the data items present in a particular row. Columns can categorize as vertical, and Rows are horizontal.

Fields are the components to provide the structure for the table. It stores the same category of data in the same data type. A table contains a fixed number of columns but can have any number of rows known as the record. It is also called a column in the table of the database. It represents the attribute or characteristics of the entity in the record.

Example

Table: Student

Field: Stud_rollno, Stud_name, Date of Birth, Branch, etc.


10) What is a primary key?

A primary key is a field or the combination of fields that uniquely identify each record in the table. It is one of a special kind of unique key. If the column contains a primary key, it cannot be null or empty. A table can have duplicate columns, but it cannot have more than one primary key. It always stores unique values into a column. For example, the ROLL Number can be treated as the primary key for a student in the university or college.

SQL Interview Questions and Answers

We can define a primary key into a student table as follows:

  1. CREATE TABLE Student (    
  2.     roll_number INT PRIMARY KEY,    
  3.     name VARCHAR(45),     
  4. );    


11) What is a foreign key?

The foreign key is used to link one or more tables together. It is also known as the referencing key. A foreign key is specified as a key that is related to the primary key of another table. It means a foreign key field in one table refers to the primary key field of the other table. It identifies each row of another table uniquely that maintains the referential integrity. The primary key-foreign key relationship is a very crucial relationship as it maintains the ACID properties of the database sometimes. It also prevents actions that would destroy links between the child and parent tables.

We can define a foreign key into a table as follows:

  1. CONSTRAINT constraint_name]    
  2.     FOREIGN KEY [foreign_key_name] (col_name, …)    
  3.     REFERENCES parent_tbl_name (col_name,…)    


12) What is a unique key?

A unique key is a single or combination of fields that ensure all values stores in the column will be unique. It means a column cannot stores duplicate values. This key provides uniqueness for the column or set of columns. For example, the email addresses and roll numbers of student’s tables should be unique. It can accept a null value but only one null value per column. It ensures the integrity of the column or group of columns to store different values into a table.

We can define a foreign key into a table as follows:

  1. CREATE TABLE table_name(    
  2.     col1 datatype,    
  3.     col2 datatype UNIQUE,    
  4.     …    
  5. );  


13) What is the difference between a primary key and a unique key?

The primary key and unique key both are essential constraints of the SQL. The main difference among them is that the primary key identifies each record in the table. In contrast, the unique key prevents duplicate entries in a column except for a NULL value. The following comparison chart explains it more clearly:

Primary KeyUnique Key
The primary key act as a unique identifier for each record in the table.The unique key is also a unique identifier for records when the primary key is not present in the table.
We cannot store NULL values in the primary key column.We can store NULL value in the unique key column, but only one NULL is allowed.
We cannot change or delete the primary key column values.We can modify the unique key column values.


14) What is a Database?

A database is an organized collection of data that is structured into tables, rows, columns, and indexes. It helps the user to find the relevant information frequently. It is an electronic system that makes data access, data manipulation, data retrieval, data storing, and data management very easy. Almost every organization uses the database for storing the data due to its easily accessible and high operational ease. The database provides perfect access to data and lets us perform required tasks.

The following are the common features of a database:

  • Manages large amounts of data
  • Accurate
  • Easy to update
  • Security
  • Data integrity
  • Easy to research data

15) What is meant by DBMS?

DBMS stands for Database Management System. It is a software program that primarily functions as an interface between the database and the end-user. It provides us the power such as managing the data, the database engine, and the database schema to facilitate the organization and manipulation of data using a simple query in almost no time. It is like a File Manager that manages data in a database rather than saving it in file systems. Without the database management system, it would be far more difficult for the user to access the database’s data.

The following are the components of a DBMS:

  • Software
  • Data
  • Procedures
  • Database Languages
  • Query Processor
  • Database Manager
  • Database Engine
  • Reporting

16) What are the different types of database management systems?

The database management systems can be categorized into several types. Some of the important lists are given below:

  • Hierarchical databases (DBMS)
  • Network databases (IDMS)
  • Relational databases (RDBMS
  • Object-oriented databases
  • Document databases (Document DB)
  • Graph databases
  • ER model databases
  • NoSQL databases

17) What is RDBMS?

RDBMS stands for Relational Database Management System. It is a database management system based on a relational model. It facilitates you to manipulate the data stored in the tables by using relational operators. RDBMS stores the data into the collection of tables and links those tables using the relational operators easily whenever required. Examples of relational database management systems are Microsoft Access, MySQL, SQL Server, Oracle database, etc.


18) What is Normalization in a Database?

Normalization is used to minimize redundancy and dependency by organizing fields and table of a database.

There are some rules of database normalization, which is commonly known as Normal From, and they are:

  • First normal form(1NF)
  • Second normal form(2NF)
  • Third normal form(3NF)
  • Boyce-Codd normal form(BCNF)

Using these steps, the redundancy, anomalies, inconsistency of the data in the database can be removed.


19) What is the primary use of Normalization?

Normalization is mainly used to add, delete or modify a field that can be made in a single table. The primary use of Normalization is to remove redundancy and remove the insert, delete and update distractions. Normalization breaks the table into small partitions and then links them using different relationships to avoid the chances of redundancy.


20) What are the disadvantages of not performing database Normalization?

The major disadvantages are:

The occurrence of redundant terms in the database causes the waste of space in the disk.

Due to redundant terms, inconsistency may also occur. If any change is made in the data of one table but not made in the same data of another table, then inconsistency will occur. This inconsistency will lead to the maintenance problem and effects the ACID properties as well.


21) What is an inconsistent dependency?

An Inconsistent dependency refers to the difficulty of getting relevant data due to a missing or broken path to the data. It leads users to search the data in the wrong table, resulting in an error as an output.


22) What is Denormalization in a Database?

Denormalization is a technique used by database administrators to optimize the efficiency of their database infrastructure. The denormalization concept is based on Normalization, which is defined as arranging a database into tables correctly for a particular purpose. This method allows us to add redundant data into a normalized database to alleviate issues with database queries that merge data from several tables into a single table. It adds redundant terms into the tables to avoid complex joins and many other complex operations.

Denormalization doesn’t mean that normalization will not be done. It is an optimization strategy that takes place after the normalization process.


23) What are the different types of SQL operators?

Operators are the special keywords or special characters reserved for performing particular operations. They are also used in SQL queries. We can primarily use these operators within the WHERE clause of SQL commands. It’s a part of the command to filters data based on the specified condition. The SQL operators can be categorized into the following types:

  • Arithmetic operators: These operators are used to perform mathematical operations on numerical data. The categories of this operators are addition (+), subtraction (-), multiplication (*), division (/), remainder/modulus (%), etc.
  • Logical operators: These operators evaluate the expressions and return their results in True or False. This operator includes ALL, AND, ANY, ISNULL, EXISTS, BETWEEN, IN, LIKE, NOT, OR, UNIQUE.
  • Comparison operators: These operators are used to perform comparisons of two values and check whether they are the same or not. It includes equal to (=), not equal to (!= or <>), less than (<), greater than (>), less than or equal to (<=), greater than or equal to (>=), not less than (!<), not greater than (!>), etc.
  • Bitwise operators: It is used to do bit manipulations between two expressions of integer type. It first performs conversion of integers into binary bits and then applied operators such as AND (& symbol), OR (|, ^), NOT (~), etc.
  • Compound operators: These operators perform operations on a variable before setting the variable’s result to the operation’s result. It includes Add equals (+=), subtract equals (-=), multiply equals (*=), divide equals (/=), modulo equals (%=), etc.
  • String operators: These operators are primarily used to perform concatenation and pattern matching of strings. It includes + (String concatenation), += (String concatenation assignment), % (Wildcard), [] (Character(s) matches), [^] (Character(s) not to match), _ (Wildcard match one character), etc.

24) What is a view in SQL?

A view is a database object that has no values. It is a virtual table that contains a subset of data within a table. It looks like an actual table containing rows and columns, but it takes less space because it is not present physically. It is operated similarly to the base table but does not contain any data of its own. Its name is always unique. A view can have data from one or more tables. If any changes occur in the underlying table, the same changes reflected in the views also.

SQL Interview Questions and Answers

The primary use of a view is to implement the security mechanism. It is the searchable object where we can use a query to search the view as we use for the table. It only shows the data returned by the query that was declared when the view was created.

We can create a view by using the following syntax:

  1. CREATE VIEW view_name AS  
  2. SELECT column_lists FROM table_name  
  3. WHERE condition;  

25) What is an Index in SQL?

An index is a disc structure associated with a table or view that speeds up row retrieval. It reduces the cost of the query because the query’s high cost will lead to a fall in its performance. It is used to increase the performance and allow faster retrieval of records from the table. Indexing reduces the number of data pages we need to visit to find a particular data page. It also has a unique value meaning that the index cannot be duplicated. An index creates an entry for each value which makes it faster to retrieve data.

For example: Suppose we have a book which carries the details of the countries. If you want to find out information about India, why will you go through every page of that book? You could directly go to the index. Then from the index, you can go to that particular page where all the information about India is given.


26) What are the different types of indexes in SQL?

SQL indexes are nothing more than a technique of minimizing the query’s cost. The higher the query’s cost, the worse the query’s performance. The following are the different types of Indexes supported in SQL:

  • Unique Index
  • Clustered Index
  • Non-Clustered Index
  • Bit-Map Index
  • Normal Index
  • Composite Index
  • B-Tree Index
  • Function-Based Index

27) What is the unique index?

UNIQUE INDEX is used to enforce the uniqueness of values in single or multiple columns. We can create more than one unique index in a single table. For creating a unique index, the user has to check the data in the column because the unique indexes are used when any column of the table has unique values. This indexing does not allow the field to have duplicate values if the column is unique indexed. A unique index can be applied automatically when a primary key is defined.

We can create it by using the following syntax:

  1. CREATE UNIQUE INDEX index_name    
  2. ON table_name (index_column1, index_column2,…);  

Example

  1. CREATE TABLE Employee(      
  2.     ID int AUTO_INCREMENT PRIMARY KEY,       
  3.     Name varchar(45),     
  4.     Phone varchar(15),    
  5.     City varchar(25),   
  6. );  

Suppose we want to make a Phone column as a unique index. We can do this like below:

  1. CREATE UNIQUE INDEX index_name_phone ON Employee (Phone);    


28) What is clustered index in SQL?

A clustered index is actually a table where the data for the rows are stored. It determines the order of the table data based on the key values that can sort in only one direction. Each table can have only one clustered index. It is the only index, which has been automatically created when the primary key is generated. If many data modifications needed to be done in the table, then clustered indexes are preferred.


29) What is the non-clustered index in SQL?

The indexes other than PRIMARY indexes (clustered indexes) are called non-clustered indexes. We know that clustered indexes are created automatically when primary keys are generated, and non-clustered indexes are created when multiple joins conditions and various filters are used in the query. The non-clustered index and table data are both stored in different places. It cannot be able to alter the physical order of the table and maintains the logical order of data.

The purpose of creating a non-clustered index is for searching the data. Its best example is a book where the content is written in one place, and the index is at a different place. We can create 0 to 249 non-clustered indexes in each table. The non-clustered indexing improves the performance of the queries which use keys without assigning the primary key.


30) What are the differences between SQL, MySQL, and SQL Server?

The following comparison chart explains their main differences:

SQLMySQLSQL Server
SQL or Structured Query Language is useful for managing our relational databases. It is used to query and operate the database.MySQL is the popular database management system used for managing the relational database. It is a fast, scalable, and easy-to-use database.SQL Server is an RDBMS database system mainly developed for the Windows system to store, retrieve, and access data requested by the developer.
SQL first appeared in 1974.MySQL first appeared on May 23, 1995.SQL Server first appeared on April 24, 1989.
SQL was developed by IBM Corporation.MySQL was developed by Oracle Corporation.SQL Server was developed by Microsoft Company.
SQL is a query language for managing databases.MySQL is database software that uses SQL language to conduct with the database.SQL Server is also a software that uses SQL language to conduct with the database.
SQL has no variables.MySQL can use variables constraints and data types.SQL Server can use variables constraints and data types.
SQL is a programming language, so that it does not get any updates. Its commands are always fixed and remain the same.MySQL is software, so it gets frequent updation.SQL Server is also software, so it gets frequent updation.

31) What is the difference between SQL and PL/SQL?

The following comparison chart explains their main differences:

SQLPL/SQL
SQL is a database structured query language used to communicate with relational databases. It was developed by IBM Corporations and first appeared in 1974.PL/SQL or Procedural Language/Structured Query Language is a dialect of SQL used to enhance the capabilities of SQL. Oracle Corporation developed it in the early 90’s. It uses SQL as its database language.
SQL is a declarative and data-oriented language.PL/SQL is a procedural and application-oriented language.
SQL has no variables.PL/SQL can use variables constraints and data types.
SQL can execute only a single query at a time.PL/SQL can execute a whole block of code at once.
SQL query can be embedded in PL/SQL.PL/SQL cannot be embedded in SQL as SQL does not support any programming language and keywords.
SQL can directly interact with the database server.PL/SQL cannot directly interact with the database server.
SQL is like the source of data that we need to display.PL/SQL provides a platform where SQL data will be shown.

32) Is it possible to sort a column using a column alias?

Yes. We can use the alias method in the ORDER BY instead of the WHERE clause for sorting a column.


33) What is the difference between clustered and non-clustered indexes in SQL?

Indexing is a method to get the requested data very fast. There are mainly two types of indexes in SQL, clustered index and non-clustered index. The differences between these two indexes are very important from an SQL performance perspective. The following comparison chart explains their main differences:

Clustered IndexNon-Clustered Index
A clustered index is a table or view where the data for the rows are stored. In a relational database, if the table column contains a primary key, MySQL automatically creates a clustered index named PRIMARY.The indexes other than PRIMARY indexes (clustered indexes) are called non-clustered indexes. It has a structure separate from the data row. The non-clustered indexes are also known as secondary indexes.
Clustered indexes store the data information and the data itself.Non-clustered indexes stores only the information, and then it will refer you to the data stored in clustered data.
There can only be one clustered index per table.There can be one or more non-clustered indexes in a table.
A clustered index determines how data is stored physically in the table. Therefore, reading from a clustered index is faster.It creates a logical ordering of data rows and uses pointers for accessing the physical data files. Therefore, reading from a clustered index is slower.
A clustered index always contains an index id of 0.A non-clustered index always contains an index id>0.

To read more information, click here.


34) What is the SQL query to display the current date?

There is a built-in function in SQL called GetDate(), which is used to return the current timestamp.


35) Which are joins in SQL? Name the most commonly used SQL joins?

SQL joins are used to retrieve data from multiple tables into a meaningful result set. It is performed whenever you need to fetch records from two or more tables. They are used with SELECT statement and join conditions.

The following are the most commonly used joins in SQL:

  • INNER JOIN
  • LEFT OUTER JOIN
  • RIGHT OUTER JOIN

36) What are the different types of joins in SQL?

Joins are used to merge two tables or retrieve data from tables. It depends on the relationship between tables. According to the ANSI standard, the following are the different types of joins used in SQL:

  • INNER JOIN
  • SELF JOIN
  • LEFT OUTER JOIN
  • RIGHT OUTER JOIN
  • FULL OUTER JOIN
  • CROSS JOIN
SQL Interview Questions and Answers


37) What is INNER JOIN in SQL?

Inner join returns only those records from the tables that match the specified condition and hides other rows and columns. In simple words, it fetches rows when there is at least one match of rows between the tables is found. INNER JOIN keyword joins the matching records from two tables. It is assumed as a default join, so it is optional to use the INNER keyword with the query.

The below visual representation explain this join more clearly:

SQL Interview Questions and Answers

The following syntax illustrates the INNER JOIN:

  1. SELECT column_lists  
  2. FROM table1    
  3. INNER JOIN table2 ON join_condition1    
  4. INNER JOIN table3 ON join_condition2    
  5. …;    


38) What is the Right JOIN in SQL?

The Right join is used to retrieve all rows from the right-hand table and only those rows from the other table that fulfilled the join condition. It returns all the rows from the right-hand side table even though there are no matches in the left-hand side table. If it finds unmatched records from the left side table, it returns a Null value. This join is also known as Right Outer Join.

The below visual representation explain this join more clearly:

SQL Interview Questions and Answers

The following syntax illustrates the RIGHT JOIN:

  1. SELECT colum_lists    
  2. FROM table1     
  3. RIGHT JOIN table2    
  4. ON join_condition;  


39) What is Left Join in SQL?

The Left Join is used to fetch all rows from the left-hand table and common records between the specified tables. It returns all the rows from the left-hand side table even though there are no matches on the right-hand side table. If it will not find any matching record from the right side table, then it returns null. This join can also be called a Left Outer Join.

The following visual representation explains it more clearly:

SQL Interview Questions and Answers

The following syntax illustrates the RIGHT JOIN:

  1. SELECT colum_lists    
  2. FROM table1     
  3. LEFT JOIN table2    
  4. ON join_condition;  


40) What is Full Join in SQL?

The Full Join results from a combination of both left and right join that contains all the records from both tables. It fetches rows when there are matching rows in any one of the tables. This means it returns all the rows from the left-hand side table and all the rows from the right-hand side tables. If a match is not found, it puts NULL value. It is also known as FULL OUTER JOIN.

The following visual representation explains it more clearly:

SQL Interview Questions and Answers

The following syntax illustrates the FULL JOIN:

  1. SELECT * FROM table1     
  2. FULL OUTER JOIN table2    
  3. ON join_condition;  


41) What is a “TRIGGER” in SQL?

A trigger is a set of SQL statements that reside in a system catalog. It is a special type of stored procedure that is invoked automatically in response to an event. It allows us to execute a batch of code when an insert, update or delete command is run against a specific table because the trigger is the set of activated actions whenever DML commands are given to the system.

SQL triggers have two main components one is action, and another is an event. When certain actions are taken, an event occurs as a result of those actions.

We use the CREATE TRIGGER statement for creating a trigger in SQL. Here is the syntax:

  1. CREATE TRIGGER trigger_name      
  2.     (AFTER | BEFORE) (INSERT | UPDATE | DELETE)    
  3.          ON table_name FOR EACH ROW      
  4.          BEGIN      
  5.         –variable declarations      
  6.         –trigger code      
  7.         END; 

42) What is self-join and what is the requirement of self-join?

A SELF JOIN is used to join a table with itself. This join can be performed using table aliases, which allow us to avoid repeating the same table name in a single sentence. It will throw an error if we use the same table name more than once in a single query without using table aliases.

A SELF JOIN is required when we want to combine data with other data in the same table itself. It is often very useful to convert a hierarchical structure to a flat structure.

The following syntax illustrates the SELF JOIN:

  1. SELECT column_lists    
  2. FROM table1 AS T1, table1 AS T2    
  3. WHERE join_conditions;    

Example

Suppose we have a table ‘Student’ having the following data:

SQL Interview Questions and Answers

If we want to get retrieve the student_id and name from the table where student_id is equal, and course_id is not equal, it can be done by using the self-join:

  1. SELECT  s1.student_id, s1.name    
  2. FROM student AS s1, student s2    
  3. WHERE s1.student_id=s2.student_id    
  4. AND s1.course_id<>s2.course_id;    

Here is the result:

SQL Interview Questions and Answers


43) What are the set operators in SQL?

We use the set operators to merge data from one or more tables of the same kind. Although the set operators are like SQL joins, there is a significant distinction. SQL joins combine columns from separate tables, whereas SQL set operators combine rows from different queries. SQL queries that contain set operations are called compound queries. The set operators in SQL are categories into four different types:

SQL Interview Questions and Answers

A. UNION: It combines two or more results from multiple SELECT queries into a single result set. It has a default feature to remove the duplicate rows from the tables. The following syntax illustrates the Union operator:

  1. SELECT columns FROM table1    
  2. UNION    
  3. SELECT columns FROM table2;    

B. UNION ALL: This operator is similar to the Union operator, but it does not remove the duplicate rows from the output of the SELECT statements. The following syntax illustrates the UNION ALL operator:

  1. SELECT columns FROM table1    
  2. UNION  ALL  
  3. SELECT columns FROM table2;    

C. INTERSECT: This operator returns the common records from two or more SELECT statements. It always retrieves unique records and arranges them in ascending order by default. Here, the number of columns and data types should be the same. The following syntax illustrates the INTERSECT operator:

  1. SELECT columns FROM table1    
  2. INTERSECT  
  3. SELECT columns FROM table2;    

D. MINUS: This operator returns the records from the first query, which is not found in the second query. It does not return duplicate values. The following syntax illustrates the MINUS operator:

  1. SELECT columns FROM table1    
  2. MINUS  
  3. SELECT columns FROM table2;    


44) What is the difference between IN and BETWEEN operators?

The following comparison chart explains their main differences:

BETWEEN OperatorIN Operator
This operator is used to selects the range of data between two values. The values can be numbers, text, and dates as well.It is a logical operator to determine whether or not a specific value exists within a set of values. This operator reduces the use of multiple OR conditions with the query.
It returns records whose column value lies in between the defined range.It compares the specified column’s value and returns the records when the match exists in the set of values.
The following syntax illustrates this operator:
SELECT * FROM table_name
WHERE column_name BETWEEN ‘value1’ AND ‘value2’;
The following syntax illustrates this operator:
SELECT * FROM table_name
WHERE column_name IN (‘value1′,’value 2’);

45) What is a constraint? Tell me about its various levels.

The constraint is used to specify the rule and regulations that allows or restricts what values/data will be stored in the table. It ensures data accuracy and integrity inside the table. It enforces us to store valid data and prevents us from storing irrelevant data. If any interruption occurs between the constraint and data action, the action is failed. Some of the most commonly used constraints are NOT NULL, PRIMARY KEY, FOREIGN KEY, AUTO_INCREMENT, UNIQUE KEY, etc.

The following syntax illustrates us to create a constraint for a table:

  1. CREATE TABLE table_name (    
  2.     column1 datatype constraint,    
  3.     column2 datatype constraint,   
  4.     ………    
  5. );    

SQL categories the constraints into two levels:

Column Level Constraints: These constraints are only applied to a single column and limit the type of data that can be stored in that column.

Table Level Constraints: These constraints are applied to the entire table and limit the type of data that can be entered.


46) How to write an SQL query to find students’ names start with ‘A’?

We can write the following query to get the student details whose name starts with A:

  1. SELECT * FROM student WHERE stud_name like ‘A%’;  

Here is the demo example where we have a table named student that contains two names starting with the ‘A’ character.

SQL Interview Questions and Answers

47) Write the SQL query to get the third maximum salary of an employee from a table named employees.

The following query is the simplest way to get the third maximum salary of an employee:

  1. SELECT * FROM `employees` ORDER BY `salary` DESC LIMIT 1 OFFSET 2  

Here is the demo example that shows how to get the third maximum salary of an employee.

SQL Interview Questions and Answers

The following are the alternative way to get the third-highest salary of an employee:

A. Using LIMIT Keyword

  1. SELECT salary FROM employees   
  2. ORDER BY salary DESC   
  3. LIMIT 2, 1;  

B. Using Subquery

  1. SELECT salary    
  2. FROM   
  3.     (SELECT salary   
  4.      FROM employees   
  5.      ORDER BY salary DESC   
  6.      LIMIT 3) AS Temp   
  7. ORDER BY salary LIMIT 1;  

C. Using TOP Keyword

  1. SELECT TOP 1 salary   
  2. FROM   
  3.     (SELECT DISTINCT TOP 3 salary   
  4.      FROM employees   
  5.      ORDER BY salary DESC) AS Temp   
  6. ORDER BY salary ASC;  

48) What is the difference between DELETE and TRUNCATE statements in SQL?

The main difference between them is that the delete statement deletes data without resetting a table’s identity, whereas the truncate command resets a particular table’s identity. The following comparison chart explains it more clearly:

No.DELETETRUNCATE
1)The delete statement removes single or multiple rows from an existing table depending on the specified condition.The truncate command deletes the whole contents of an existing table without the table itself. It preserves the table structure or schema.
2)DELETE is a DML command.TRUNCATE is a DML command.
3)We can use the WHERE clause in the DELETE command.We cannot use the WHERE clause with TRUNCATE.
4)DELETE statement is used to delete a row from a table.TRUNCATE statement is used to remove all the rows from a table.
5)DELETE is slower because it maintained the log.TRUNCATE statement is faster than DELETE statement as it deletes entire data at a time without maintaining transaction logs.
6)You can roll back data after using the DELETE statement.It is not possible to roll back after using the TRUNCATE statement.
7)DELETE query takes more space.TRUNCATE query occupies less space.


49) What is the ACID property in a database?

The ACID properties are meant for the transaction that goes through a different group of tasks. A transaction is a single logical order of data. It provides properties to maintain consistency before and after the transaction in a database. It also ensures that the data transactions are processed reliably in a database system.

The ACID property is an acronym for Atomicity, Consistency, Isolation, and Durability.

Atomicity: It ensures that all statements or operations within the transaction unit must be executed successfully. If one part of the transaction fails, the entire transaction fails, and the database state is left unchanged. Its main features are COMMIT, ROLLBACK, and AUTO-COMMIT.

Consistency: This property ensures that the data must meet all validation rules. In simple words, we can say that the database changes state only when a transaction will be committed successfully. It also protects data from crashes.

Isolation: This property guarantees that the concurrent property of execution in the transaction unit must be operated independently. It also ensures that statements are transparent to each other. The main goal of providing isolation is to control concurrency in a database.

Durability: This property guarantees that once a transaction has been committed, it persists permanently even if the system crashes, power loss, or failed.


50) Is a blank space or zero the same as a NULL value?

No. The NULL value is not the same as zero or a blank space. The following points explain their main differences:

  • A NULL value is a value, which is ‘unavailable, unassigned, unknown or not applicable.’ It would be used in the absence of any value. We can perform arithmetic operations on it. On the other hand, zero is a number, and a blank space is treated as a character.
  • The NULL value can be treated as an unknown and missing value, but zero and blank spaces differ from the NULL value.
  • We can compare a blank space or a zero to another blank space or a zero. On the other hand, one NULL may not be the same as another NULL. NULL indicates that no data has been provided or that no data exists.

51) What are functions and their usage in SQL?

SQL functions are simple code snippets that are frequently used and re-used in database systems for data processing and manipulation. Functions are the measured values. It always performs a specific task. The following rules should be remembered while creating functions:

  • A function should have a name, and the name cannot begin with a special character such as @, $, #, or other similar characters.
  • Functions can only work with the SELECT statements.
  • Every time a function is called, it compiles.
  • Functions must return value or result.
  • Functions are always used with input parameters.

SQL categories the functions into two types:

  • User-Defined Function: Functions created by a user based on their needs are termed user-defined functions.
  • System Defined Function: Functions whose definition is defined by the system are termed system-defined functions. They are built-in database functions.

SQL functions are used for the following purposes:

  • To perform calculations on data
  • To modify individual data items
  • To manipulate the output
  • To format dates and numbers
  • To convert data types

52) What is meant by case manipulation functions? Explains its different types in SQL.

Case manipulation functions are part of the character functions. It converts the data from the state in which it is already stored in the table to upper, lower, or mixed case. The conversion performed by this function can be used to format the output. We can use it in almost every part of the SQL statement. Case manipulation functions are mostly used when you need to search for data, and you don’t have any idea that the data you are looking for is in lower case or upper case.

There are three case manipulation functions in SQL:

LOWER: This function is used to converts a given character into lowercase. The following example will return the ‘STEPHEN’ as ‘stephen’:

  1. SELECT LOWER (‘STEPHEN’) AS Case_Reault FROM dual;  

NOTE: Here, ‘dual’ is a dummy table.

UPPER: This function is used to converts a given character into uppercase. The following example will return the ‘stephen’ as ‘STEPHEN’:

  1. SELECT UPPER (‘stephen’) AS Case_Reault FROM dual;  

INITCAP: This function is used to converts given character values to uppercase for the initials of each word. It means every first letter of the word is converted into uppercase, and the rest is in lower case. The following example will return the ‘hello stephen’ as ‘Hello Stephen’:

  1. SELECT INITCAP (‘hello stephen’) AS Case_Reault FROM dual;  

53) Explain character-manipulation functions? Explains its different types in SQL.

Character-manipulation functions are used to change, extract, and alter the character string. When one or more characters and words are passed into the function, the function will perform its operation on those input strings and return the result.

The following are the character manipulation functions in SQL:

A) CONCAT: This function is used to join two or more values together. It always appends the second string into the end of the first string. For example:

Input: SELECT CONCAT (‘Information-‘, ‘technology’) FROM DUAL;

Output: Information-technology

B) SUBSTR: It is used to return the portion of the string from a specified start point to an endpoint. For example:

Input: SELECT SUBSTR (‘Database Management System’, 9, 11) FROM DUAL;

Output: Management

C) LENGTH: This function returns the string’s length in numerical value, including the blank spaces. For example:

Input: SELECT LENGTH (‘Hello Javatpoint’) FROM DUAL;

Output: 16

D) INSTR: This function finds the exact numeric position of a specified character or word in a given string. For example:

Input: SELECT INSTR (‘Hello Javatpoint’, ‘Javatpoint’);

Output: 7

E) LPAD: It returns the padding of the left-side character value for right-justified value. For example:

Input: SELECT LPAD (‘200′, 6,’*’);

Output: ***200

F) RPAD: It returns the padding of the right-side character value for left-justified value. For example:

Input: SELECT RPAD (‘200′, 6,’*’);

Output: 200***

G) TRIM: This function is used to remove all the defined characters from the beginning, end, or both. It also trimmed extra spaces. For example:

Input: SELECT TRIM (‘A’ FROM ‘ABCDCBA’);

Output: BCDCB

H) REPLACE: This function is used to replace all occurrences of a word or portion of the string (substring) with the other specified string value. For example:

Input: SELECT REPLACE ( ‘It is the best coffee at the famous coffee shop.’, ‘coffee’, ‘tea’);

Output: It is the best tea at the famous tea shop.


54) What is the usage of the NVL() function?

The NVL() function is used to convert the NULL value to the other value. The function returns the value of the second parameter if the first parameter is NULL. If the first parameter is anything other than NULL, it is left unchanged. This function is used in Oracle, not in SQL and MySQL. Instead of NVL() function, MySQL have IFNULL() and SQL Server have ISNULL() function.


55) Which function is used to return remainder in a division operator in SQL?

The MOD function returns the remainder in a division operation.


56) What are the syntax and use of the COALESCE function?

The COALESCE() function evaluates the arguments in sequence and returns the first NON-NULL value in a specified number of expressions. If it evaluates arguments as NULL or not found any NON-NULL value, it returns the NULL result.

The syntax of COALESCE function is given below:

  1. COALESCE (exp1, exp2, …. expn)   

Example:

  1. SELECT COALESCE(NULL, ‘Hello’, ‘Javatpoint’, NULL) AS Result;  

This statement will return the following output:

SQL Interview Questions and Answers

57) How do we use the DISTINCT statement? What is its use?

The DISTINCT keyword is used to ensure that the fetched value always has unique values. It does not allow to have duplicate values. The DISTINCT keyword is used with the SELECT statement and retrieves different values from the table’s column. We can use it with the help of the following syntax:

  1. SELECT DISTINCT column_lists FROM table_name WHERE [condition];  

Suppose we have a table ‘customer’ containing eight records in which the name column has some duplicate values.

SQL Interview Questions and Answers

If we want to get the name column without any duplicate values, the DISTINCT keyword is required. Executing the below command will return a name column with unique values.

SQL Interview Questions and Answers

58) What is the default ordering of data using the ORDER BY clause? How could it be changed?

The ORDER BY clause is used to sort the table data either in ascending or descending order. By default, it will sort the table in ascending order. If we want to change its default behavior, we need to use the DESC keyword after the column name in the ORDER BY clause.

The syntax to do this is given below:

  1. SELECT expressions FROM tables    
  2. WHERE conditions    
  3. ORDER BY expression [ASC | DESC];    

We have taken a customer table in the previous example. Now, we will demonstrate the ORDER BY clause on them as well.

In the below output, we can see that the first query will sort the table data in ascending order based on the name column. However, if we run the second query by specifying the DESC keyword, the table’s order is changed in descending order.

SQL Interview Questions and Answers

59) Is the following query returns the output?

  1. SELECT subject_code, AVG (marks)  
  2. FROM Students  
  3. WHERE AVG(marks) > 70  
  4. GROUP BY subject_code;  

Answer: No. The above query does not return the output because we cannot use the WHERE clause to restrict the groups. We need to use the HAVING clause instead of the WHERE clause to get the correct output.


60) What is the difference between the WHERE and HAVING clauses?

The main difference is that the WHERE clause is used to filter records before any groupings are established, whereas the HAVING clause is used to filter values from a group. The below comparison chart explains the most common differences:

WHEREHAVING
This clause is implemented in row operations.This clause is implemented in column operations.
It does not allow to work with aggregate functions.It can work with aggregate functions.
This clause can be used with the SELECT, UPDATE, and DELETE statements.This clause can only be used with the SELECT statement.


61) How many Aggregate functions are available in SQL?

The aggregate function is used to determine and calculate several values in a table and return the result as a single number. For example, the average of all values, the sum of all values, and the maximum and minimum value among particular groupings of values.

The following syntax illustrates how to use aggregate functions:

  1. function_name (DISTINCT | ALL expression)    

SQL provides seven (7) aggregate functions, which are given below:

  • AVG(): This function is used to returns the average value from specified columns.
  • COUNT(): This function is used to returns the number of table rows, including rows with null values.
  • MAX(): This function is used to returns the largest value among the group.
  • MIN(): This function is used to returns the smallest value among the group.
  • SUM(): This function is used to returns the total summed values(non-null) of the specified column.
  • FIRST(): This function is used to returns the first value of an expression.
  • LAST(): This function is used to returns the last value of an expression.

62) What is SQL Injection?

SQL injection is a type of vulnerability in website and web app code that allows attackers to control back-end operations and access, retrieve, and destroy sensitive data from databases. In this technique, malicious SQL statements are inserted into a database entry field, and once they are performed, the database becomes vulnerable to an attacker. This technique is commonly used to access sensitive data and perform administrative activities on databases by exploiting data-driven applications. It is also known as SQLi attack.

Some common examples of SQL injection are:

  • Accessing confidential data to modify an SQL query to get desired results.
  • UNION attacks to steal data from different database tables.
  • Examine the database to extract information regarding the version and structure of the database.

63) What is the difference between the RANK() and DENSE_RANK() functions?

The RANK function determines the rank for each row within your ordered partition in the result set. If the two rows are assigned the same rank, then the next number in the ranking will be its previous rank plus a number of duplicate numbers. For example, if we have three records at rank 4, the next rank listed would be ranked 7.

The DENSE_RANK function assigns a unique rank for each row within a partition as per the specified column value without any gaps. It always specifies ranking in consecutive order. If the two rows are assigned the same rank, this function will assign it with the same rank, and the next rank being the next sequential number. For example, if we have 3 records at rank 4, the next rank listed would be ranked 5.


64) Is it possible to implicitly insert a row for the identity column?

Yes. We can implicitly insert a row for the identity column. Here is an example of doing this:

  1. SET IDENTITY_INSERT TABLE1 ON  
  2. INSERT INTO demo_table1 (id, name, branch)  
  3. SELECT id, name, branch FROM demo_table2  
  4. SET IDENTITY_INSERT OFF  

65) What are SQL comments?

Comments are explanations or annotations in SQL queries that are readable by programmers. It’s used to make SQL statements easier to understand for humans. During the parsing of SQL code, it will be ignored. Comments can be written on a single line or across several lines.

  • Single Line Comments: It starts with two consecutive hyphens (–).
  • Multi-line Comments: It starts with /* and ends with */.
Uncategorized

API Testing Interview Questions

API Testing Interview Questions

A list of frequently asked API Testing interview questions and answers are given below.

1) What is API?

API (Application Programming Interface) helps in communication and data exchange between two software systems. API act as an interface between two applications and allows the two software systems communicate with one another. API is a collection of functions which can be executed by another software program.

API works as; it takes a request from the source, takes that request to the database, fetches the request data from the database and returns a response to the source. API takes the requests from the user and gives the response without exposing the internal details. API acts as Abstraction.

Example: Amazon API, Google Map API


2) What is API testing?

API testing is a type of software testing that involves testing APIs directly. API is a part of integration testing to check whether the API meets expectations in terms of functionality, reliability, performance, and security of applications. Multiple API system can performed API testing. In API testing, our primary focus is on Business Logic Layer of the software architecture.


3) What are the types of API testing?

API testing involves the following types of testing:

  • Unit Testing
  • Functional Testing
  • Load Testing
  • Runtime/Error Detection
  • Security Testing
  • UI Testing
  • Interoperability and WS compliance Testing
  • Penetration Testing
  • Fuzz Testing

4) What are the protocols used in API Testing?

Protocols used in API testing are:

  • HTTP
  • REST
  • SOAP
  • JMS
  • UDDI

5) What are the tools used for API Testing?

Tools used for API testing are:

  • Parasoft SOAtest
  • PostMan
  • AlertSite API monitoring

6) What is API test environment?

For API the test environment is a quite complex method where the configuration of server and database is done as per the requirement of the software application. API testing does not involve graphical user interface (GUI).

API is checked for its proper functioning after installation.


7) What is API framework?

API framework is described by the config. File which consist of the list of all APIs that are required to be activated and are activated for any particular program run. This is essential as every test run does not require all APIs.


8) What are the limits of API usage?

Many APIs have certain limit set up by the provider. Hence, try to estimate our usage and understand how that will impact the overall cost of the offering.


9) What are the advantages of API testing?

Advantages of API testing are:

  • Test for core functionality: API testing provides access to the application without the user interface. The core functionality of the application will be tested before the GUI tests. This will help to detect the minor issue which can become bigger during the GUI testing.
  • Time effective: API testing is less time consuming than GUI testing. Particularly, API test requires less code so it can provide better and faster test coverage compare to GUI test automation. This will reduce the cost for the testing project.
  • Language Independent: In API testing data is exchange using XML or JSON. These transfer mode are completely language-independent, which allows users to select any code language when adopting automation test service for the project.
  • Easy Integration with GUI: API tests provide highly integrable tests which is useful to perform functional GUI tests after GUI tests. Simple integration would allow new user accounts to be created within the application before GUI started.

10) What are the principles of an API test design?

Here, are the seven principles of API test design.

  1. Exhaustive Testing: Exhaustive testing is not possible. Instead we need optimal amount of testing which is based on the risk assessment of the application.
  2. Defect Clustering: Defect Clustering states that a small number of modules contain the most of the defect detected. Approximately 80% of the defect found in 20% of the modules. By experience we can identify such risky modules. But this approach has its own problems. If the same tests are repeated over and over again, eventually the same test case will no longer find new bugs.
  3. Pesticide Paradox: Testers cannot depend on existing technique. They must have to look continually to improve the existing method to make testing more effective. But even all these hard work in testing we can never claim our product is bug free. To overcome this, test cases need to be regularly reviewed and revised add new and different test cases to help find more defects.
  4. Testing shows presence of defects: Testing principle states that- testing talks about the presence of defects not about the absence of defect. Software testing reduces the probability of undiscovered defects remaining in the software but even if no defects found, it is not a proof of correctness.
  5. Absence of error -fallacy: This can be possible the software which is 99% bug free is still unusable. The case can be if the system is tested for the wrong requirement. Software testing is not finding the defects but also to check that software addresses the business needs. The absence of error is fallacy i.e. finding and fixing defects does not help if the system build is unusable and doesn’t fulfill the user’s needs and requirements.
  6. Early Testing: Testing should start as soon as possible in the software development lifecycle. So that defects in the requirement or design phase captured in the early stages. It is cheaper to fix defect in the early stages of testing. We should start finding the bug at the moment the requirements are defined.
  7. Testing is context dependent: Testing is context dependent that we test an e-commerce site will be different from the way we test the commercial. All the developed software’s are not identical. We will use different methodology; techniques and type of testing depend on the application type.

11) What is API framework?

A framework or software framework is a platform for developing software applications. API framework is a foundation on which software developer can build applications for a specific platform.

Example: A framework can include predefined classes and functions that can be used to process input, manage hardware devices and interact with system software.

Framework is similar to an Application Programming Interface, technically framework includes API. Framework serves foundation for programming while API provides access to the elements supported by the framework. Framework also includes code libraries, compiler and other programs used in the software development process.

API framework is defined by configuration file which consists the list of all APIs that is required to be activated and activated for a particular program run.


12) What are the common tests that performed on API?

Here, are the common tests that performed on API are as:

  1. Response of the API should be verified based on the request. We will verify that the return value is based on request.
  2. When API is updating any data structure we should verify the system is authenticating the outcome.
  3. We will verify whether the API is trigger other event or request another API.
  4. We will verify the behavior of the API when no value is return.

13) What exactly needs to verify in API testing?

In API testing, we send a request to API with the known data and then analysis the response.

  1. We will verify the accuracy of the data.
  2. Will see the HTTP status code.
  3. We will see the response time.
  4. Error codes in case API returns any errors.
  5. Authorization would be check.
  6. Non-Functional testing such as performance testing, security testing.

14) What are the differences between API and Web Services?

Sr. No.APIWeb Services
1.API may or may not need network for its operations.Web Services always need network for its operation.
2.API can be communicated through SOAP, REST, XML-RPC and CURL calls as well.
API can also be exposed in number of ways like JAR, DLL, XML over HTTP, JSON over HTTP etc.
Web service can be communicated through SOAP, REST, AND RPC.
3.API can perform all the operations which web service can’t perform.Web service can’t perform all the operations like API.
4.All APIs are not web service.All web services are API

15) What is API documentation?

A good documentation is must for any foundation. API documentation serves as quick reference for accessing library or working within a program.

When we use any such documents, it must consists of proper plan, content source, proper layout, information related to each function etc.

There are various documentation tools like Doxygen and JavaDoc. Here, are the functions which are documented which revolve around the parameters like:

  • Function description
  • Type and syntax of error message that may occure
  • Syntax, elements and sequence needed for each parameter
  • Links regarding functions

16) What is the most used template for API documentation?

Here, are the various documentation template that make the whole process simple and easy. They are:

  • Swagger
  • Miredot
  • Slate
  • FlatDoc
  • API blueprint
  • RestDoc
  • Web service API specification

17) What are the types of bug that can be found during API testing?

API testing helps us to find many types of bugs which are:

  • Stress
  • Security
  • Duplicate or missing functionality
  • Reliability
  • Unused flags
  • Performance
  • Incompatible error handling
  • Multi-threaded issue
  • Improper errors

18) What are the difference between API testing and UI testing?

UI (User Interface) testing means the testing of the graphical user interface. The focus of UI testing is on the look and feel of the application. In user interface testing the main focus is on how users can interact with app elements such as images, fonts, layout etc. are checked.

API testing allows the communication between two software systems. API testing works on backend also known as backend testing.


19) What is SOAP?

SOAP (Simple Object Access Control) . It is an XML based protocol that helps in exchanging information among computers.


20) What is REST API?

REST API is a set of function helps the developers performing requests when the response is receiving. Through HTTP protocol interaction is made in REST API.

REST is defined as Representational state transfer. It is an effective standard for API creation.


21) What are the differences between SOAP and REST API?

Sr. No.SOAP APIREST API
1.SOAP stands as Simple Object Access Protocol.REST stands as Representational State Transfer.
2.SOAP is a protocol.REST is an architectural pattern.
3.SOAP can work with XML format. In SOAP all the data passed in XML format.REST permit different data format such as Plain text, HTML, XML, JSON etc. But the most preferred format for transferring data is in JSON.

22) What are the major challenges faced during API testing?

The major challenges faced during the API testing are:

  • Parameter Selection
  • Parameter Combination
  • Call sequencing
  • Output verification and validation
  • A major challenge is providing input values which are very difficult because GUI is not available.

23) What are the difference between API Testing and Unit Testing?

Difference between API testing and Unit testing are:

Sr. No.API TestingUNIT Testing
1.API testing is a form of black box testing.Unit testing is a form of white box testing.
2.API testing is performed after the project completion during the test.Unit testing is performed when the project is created.
3.In API testing there is a wide scope of testing.In Unit testing there is a limited scope of testing we can test only the basic functionality.
4.API testing is done by the testers. The whole purpose of API testing is end to end testing of the functionality.Unit testing is done by the developer. In unit testing every functionality is separately tested.

24) What is a RESTFUL web services?

There are two kinds of web services

  1. SOAP Web Services
  2. RESTFUL Web Services

1. SOAP (Simple Object Access Protocol) – SOAP is a XML based method which is used in Web Services.

2. RESTFUL Web Services – To implement the concept of REST architecture HTTP method is used. RESTFUL Web Services defines URI (Uniform Resource Identifier), and also provides resource representation like JSON and a set of HTTP method.


25) What is Resource in REST?

REST architecture treats any content as resource, which can be text files, HTML pages, images, videos or dynamic business information. REST server gives the functionality to access the resources and modifies them. We can identify the each resources by URIs/ global IDs.


26) What is the way to represent the resource in REST?

REST uses different representation to define the resources like text, JSON and XML. The most popular representation of resources is JSON and XML.


27) What protocol is used by the RESTFUL Web Services?

RESTFUL Web Services uses the HTTP protocol. They use the HTTP protocol as a medium of communication between the client and the server.


28) What are the characteristics of REST?

Here, are the two characteristics of REST.

  1. REST is stateless. With the use of the REST API the server has no status, we can restart the server between two calls, inspite of all the data is transferred to the server.
  2. Web Services uses POST method to perform operations, while REST uses GET method to access the resources.

29) What is messaging in RESTFUL Web Services?

RESTFUL Web Services use the HTTP protocol as a communication tool between the client and the server. This is the technique when the client sends a message in the form of HTTP request the server send back the HTTP reply which is called Messaging. This message consists message data and Meta data i.e. information on the message itself.


30) What are the components of an HTTP request?

An HTTP request have five components. These are:

  1. Action showing HTTP method like GET, PUT, POST, DELETE.
  2. Uniform Resource Identifier (URI): URI is the identifier for the resource on the server.
  3. HTTP version: Indicate the HTTP version like- HTTP V1.1.
  4. Request Header: Request Header carries metadata for the HTTP request message. Metadata could be a client type, format supported by the client, format of a message body, cache setting etc.
  5. Request Body: Resource body indicates message content or resource representation.

31) What is the HTTP protocol supported by REST?

GET: GET is used to request data from the specified resource.

GET request can be cached and bookmark. It remains in the browser history and has length restriction. When dealing with sensitive data GET requests should not be used.

POST: POST is used to send data to server for creation or updating the resources.

POST requests are never cached or bookmark.

PUT: PUT replaces the current representation of the target resource with the request payload.

DELETE: DELETE removes the specified resource.

OPTIONS: OPTION is used to describe the communication option for the target resources.

HEAD: HEAD asks for response which is identical to GET requests, but without the response body.


32) Can we use GET request instead of PUT to create a resource?

PUT or POST method is used create a resource. GET is only used to request the resources.


33) What is URI? What is the purpose of web-based service and what is it’s format?

URI stands for Uniform Resource Identifier. It is a string of characters designed for unambiguous identification of resources and extensibility by the URI scheme. The purpose of URI is to locate the resource on the server hosting of the web service.

A URIs format is <protocol>://<service-name>/<Resource Type>/<ResourceID>


34) What are SOAP Web Services?

SOAP (Simple Object Access Protocol) is defined as the XML based protocol. SOAP is also known for developing and designing web services and also enable the communication between the applications developed on different platform by using different programming languages on the internet. SOAP is platform and language independent.


35) When we can use SOAP API?

We can use SOAP API to perform the operation on records like create, retrieve, update or delete. We can use API to manage password, perform searches etc.

Automation Testing

Selenium Interview Questions

Selenium Interview Questions

Selenium is based on automating web applications for testing purpose, but it is certainly not limited to just that. The web-based administration tasks can be automated as well. It automates browsers

Selenium has the support of some of the leading browser vendors who have adopted it to make Selenium an essential part of their browser. It is also the core technology in many other browser automation tools, APIs, and frameworks.

A list of most frequently asked Selenium interview questions, and their answers are given below.

Basic Level – Selenium Interview Questions

1) What is test automation or automation testing?

Automation testing uses automation tools to write and execute test cases, no manual involvement is necessary for executing an automated test suite. Testers prefer automation tools to write test scripts and test cases and then group into test suites.

Automation testing enables the use of specialized tools to automate the execution of manually designed test cases without any human intervention. Automation testing tools can access the test data, controls the execution of tests and compares the actual result against the expected result. Consequently, generating detailed test reports of the system under test.

Selenium Interview Questions

2) What are the advantages of automation testing?

Some basic Advantages of automation testing are as follows.

  • Automation testing supports both functional and performance test on an application.
  • It supports the execution of repeated test cases.
  • It facilitates parallel execution.
  • It aids in testing a large test matrix.
  • It improves accuracy because there are no chances of human errors.
  • It saves time and money.

3) Name some of the commonly used Automation Testing tools that are used for Functional Automation.

Lists of top 10 used automation testing tools for Functional Automation are as follows.

  • Teleric Test Studio, Developed by Teleric.
  • TestingWhiz
  • HPE Unified Functional Testing (HP – UFT formerly QTP)
  • Tosca Testsuite
  • Watir
  • Quick Test Professional, provided by HP.
  • Rational Robot, provided by IBM.
  • Coded UI, provided by Microsoft.
  • Selenium, open source.
  • Auto It, Open Source.

4) Name some of the commonly used Automation Testing tools that are used for Non-Functional Automation.

Lists of some commonly used Automation Testing tools for Non-Functional Automation are as follows.

  • Load Runner, provided by Hp.
  • JMeter, provided by Apache.
  • Burp Suite, provided by PortSwigger.
  • Acunetix, provided by Acunetix.

5) What is Selenium?

Selenium is a portable framework for software testing. Selenium tool facilitates with a playback tool for authoring functional tests without the need to learn a test scripting language.

Selenium is one of the most widely used open source Web UI (User Interface) automation testing suite. Jason Huggins developed Selenium in 2004 as an internal tool at Thought Works. Selenium supports automation across different browsers, platforms, and programming languages.


6) What are the different components of Selenium?

Selenium is not just a single tool but a suite of software’s, each having a different approach to support automation testing. It comprises of four major components which include:

  1. Selenium Integrated Development Environment (IDE)
  2. Selenium Remote Control (Now Deprecated)
  3. WebDriver
  4. Selenium Grid

7) List out the names of programming languages, browsers and operating systems that are supported by Selenium.

Selenium supports various operating systems, browsers and programming languages. Following is the list:

  • Programming Languages: C#, Java, Python, PHP, Ruby, Perl, JavaScript.
  • Operating Systems: Android, iOS, Windows, Linux, Mac, Solaris.
  • Browsers: Google Chrome, Mozilla Firefox, Internet Explorer, Edge, Opera, Safari, etc.

8) What are the significant changes/upgrades in various Selenium versions?

Selenium v1.0:

  • Version 1.0 was the initial release of Selenium.
  • It included three tools: Selenium IDE, Selenium RC, and Selenium Grid.

Selenium v2.0:

  • Selenium WebDriver was introduced replacing Selenium RC in version “2.0”.
  • With the onset of WebDriver, RC got deprecated and moved to the legacy package.

Selenium v3:

  • The latest release Selenium 3 has new added features and functionalities.
  • It includes Selenium IDE, Selenium WebDriver, and Selenium Grid.

9) List some of the test types that are supported by Selenium.

Different types of testing’s that we can achieve through Selenium are.

  • Functional Testing
  • Regression Testing
  • Sanity Testing
  • Smoke Testing
  • Responsive Testing
  • Cross Browser Testing
  • UI testing (black box)
  • Integration Testing

10) What is Selenium IDE?

Selenium IDE is implemented as Firefox extension which provides record and playback functionality on test scripts. It allows testers to export recorded scripts in many languages like HTML, Java, Ruby, RSpec, Python, C#, JUnit and TestNG.

Selenium IDE has limited scope, and the generated test scripts are not very robust, and portable.


11) What do you mean by Selenese?

Selenium commands, also known as “Selenese” are the set of commands used in Selenium that run your tests. For example, command – open (URL); launches the desired URL in the specified browser and it accept both relative and absolute URLs.

A sequence of Selenium commands (Selenese) together is known as a test script.


12) What are the different ways of locating a web element in Selenium?

In Selenium, web elements are identified and located with the help of Locators. Locators specify a target location which uniquely defines the web element in the context of a web application. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:

  • ID
  • ClassName
  • Name
  • TagName
  • LinkText
  • PartialLinkText
  • Xpath
  • CSS Selector
  • DOM

13) How many types of WebDriver API’s are available in Selenium?

The list of WebDriver API’s which are used to automate browser include:

  • AndroidDriver
  • ChromeDriver
  • EventFiringWebDriver
  • FirefoxDriver
  • HtmlUnitDriver
  • InternetExplorerDriver
  • iPhoneDriver
  • iPhoneSimulatorDriver
  • RemoteWebDriver

14) List out some of the Automation tools which could be integrated with Selenium to achieve continuous testing.

Selenium can be used to automate functional tests and can be integrated with automation test tools such as Maven, Jenkins, &Docker to achieve continuous testing. It can also be integrated with tools such as TestNG, &JUnit for managing test cases and generating reports.


15) What do you mean by the assertion in Selenium?

The assertion is used as a verification point. It verifies that the state of the application conforms to what is expected. The types of assertion are “assert”, “verify” and “waitFor”.


16) Explain the difference between assert and verify commands?

Assert: Assert command checks if the given condition is true or false. If the condition is true, the program control will execute the next phase of testing, and if the condition is false, execution will stop, and nothing will be executed.

Verify: Verify command also checks if the given condition is true or false. It doesn’t halt program execution, i.e., any failure during verification would not stop the execution, and all the test phases would be executed.


17) What do you mean by XPath?

XPath is also defined as XML Path. It is a language used to query XML documents. It is an important approach to locate elements in Selenium. XPath consists of a path expression along with some conditions. Here, we can easily write XPath script/query to locate any element in the webpage. It is developed to allow the navigation of XML documents. The key factors that it considered while navigating are selecting individual elements, attributes, or some other part of an XML document for specific processing. It also produces reliable locators. Some other points about XPath are as follows.

  • XPath is a language used for locating nodes in XML documents.
  • XPath can be used as a substitute when you don’t have a suitable id or name attribute for the element you want to locate.
  • XPath provides locating strategies like:
    • XPath Absolute
    • XPath Attributes

18) Explain XPath Absolute and XPath attributes.

XPath Absolute:

  • XPath Absolute enables users to mention the complete XPath location from the root HTML tag to the specific elements.
  • Syntax: //html/body/tag1[index]/tag2[index]/…/tagN[index]
  • Example: //html/body/div[2]/div/div[2]/div/div/div/fieldset/form/div[1]/input[1]

XPath Attributes:

  • XPath Attributes is always recommended when you don’t have a suitable id or name attribute for the element you want to locate.
  • Syntax: //htmltag[@attribute1=’value1′ and @attribute2=’value2′]
  • Example: //input[@id=’passwd’ and @placeholder=’password’]

19) What is the difference between “/” and “//” in XPath?

Single Slash “/”: Single slash is used to create XPath with absolute path.

Double Slash “//”: Double slash is used to create XPath with the relative path.


20) What are the different types of annotations which are used in Selenium?

JUnit annotations which can be used are:

  • Test
  • Before
  • After
  • Ignore
  • BeforeClass
  • AfterClass
  • RunWith

21) What are the WebDriver supported Mobile Testing Drivers?

WebDriver supported “mobile testing drivers” are:

  • AndroidDriver
  • IphoneDriver
  • OperaMobileDriver

22) What are the popular programming languages supported by Selenium WebDriver to write Test Cases?

Selenium WebDriver supports the below languages to write Test Cases.

  • JAVA
  • PHP
  • Python
  • C#
  • Ruby
  • Perl

23) What is the difference between type keys and type commands?

TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won’t.


24) What is the difference between “type” and “typeAndWait” command?

“type” command is used to type keyboard key values into the text box of software web application. It can also be used for selecting values of combo box whereas “typeAndWait” command is used when your typing is completed and software web page start reloading. This command will wait for software application page to reload. If there is no page reload event on typing, you have to use a simple “type” command.


25) What is the difference between findElement() and findElements()?

findElement(): It is used to find the first element within the current page using the given “locating mechanism”. It returns a single WebElement.

findElements(): It uses the given “locating mechanism” to find all the elements within the current page. It returns a list of web elements.


26) What is the wait? How many types of waits in selenium?

Selenium Webdriver introduces the concept of waits for the AJAX-based application. There are two types of waits:

  1. Implicit Wait
  2. Explicit Wait

27) What is the main disadvantage of implicit wait?

The main disadvantage of implicit wait is that it slows down test performance.

Another disadvantage of implicit wait is:

Suppose, you set the waiting limit to be 10 seconds, and the elements appear in the DOM in 11 seconds, your tests will be failed because you told it to wait a maximum of 10 seconds.


28) What is Selenium Grid?

Selenium Grid facilitates you to distribute your tests on multiple machines and all of them at the same time. So, you can execute tests on Internet Explorer on Windows and Safari on Mac machine using the same text script. It reduces the time of test execution and provides quick feedback.

Advance Level – Selenium Interview Questions

29) How can we launch different browsers in Selenium WebDriver?

We have to create an instance of a driver of that particular browser.

  1. WebDriver driver =newFirefoxDriver();  

Here, “WebDriver” is an interface, and we are creating a reference variable “driver” of type WebDriver, instantiated using “FireFoxDriver” class.


30) Write a code snippet to launch Firefox browser in WebDriver.

  1. public class FirefoxBrowserLaunchDemo {  
  2.   
  3. public static void main(String[] args) {  
  4.   
  5. //Creating a driver object referencing WebDriver interface  
  6. WebDriver driver;  
  7.   
  8. //Setting webdriver.gecko.driver property  
  9. System.setProperty(“webdriver.gecko.driver”, pathToGeckoDriver + “\\geckodriver.exe”);  
  10.   
  11. //Instantiating driver object and launching browser  
  12. driver = newFirefoxDriver();  
  13.   
  14. //Using get() method to open a webpage  
  15. driver.get(“http://javatpoint.com”);  
  16.   
  17. //Closing the browser  
  18. driver.quit();  
  19.   
  20.     }  
  21.   
  22. }  

31) Write a code snippet to launch Chrome browser in WebDriver.

  1. public class ChromeBrowserLaunchDemo {  
  2.   
  3. public static void main(String[] args) {  
  4.   
  5. //Creating a driver object referencing WebDriver interface  
  6. WebDriver driver;  
  7.   
  8. //Setting the webdriver.chrome.driver property to its executable’s location  
  9. System.setProperty(“webdriver.chrome.driver”, “/lib/chromeDriver/chromedriver.exe”);  
  10.       
  11. //Instantiating driver object  
  12. driver = newChromeDriver();  
  13.   
  14. //Using get() method to open a webpage  
  15. driver.get(“http://javatpoint.com”);  
  16.   
  17. //Closing the browser  
  18. driver.quit();  
  19.   
  20.     }  
  21.   
  22. }  

32) Write a code snippet to launch Internet Explorer browser in WebDriver.

  1. public class IEBrowserLaunchDemo {  
  2.   
  3. public static void main(String[] args) {  
  4.   
  5. //Creating a driver object referencing WebDriver interface  
  6. WebDriver driver;  
  7.   
  8. //Setting the webdriver.ie.driver property to its executable’s location  
  9. System.setProperty(“webdriver.ie.driver”, “/lib/IEDriverServer/IEDriverServer.exe”);  
  10.       
  11. //Instantiating driver object  
  12. driver = newInternetExplorerDriver();  
  13.   
  14. //Using get() method to open a webpage  
  15. driver.get(“http://javatpoint.com”);  
  16.   
  17. //Closing the browser  
  18. driver.quit();  
  19.   
  20.     }  
  21.   
  22. }  

33) Write a code snippet to perform right-click an element in WebDriver.

We will use Action class to generate user event like right-click an element in WebDriver.

  1. Actions action = newActions(driver);  
  2. WebElement element = driver.findElement(By.id(“elementId”));  
  3. action.contextClick(element).perform();  

34) Write a code snippet to perform mouse hover in WebDriver.

  1. Actions action = newActions(driver);  
  2. WebElement element = driver.findElement(By.id(“elementId”));  
  3. action.moveToElement(element).perform();  

35) How do you perform drag and drop operation in WebDriver?

Code snippet to perform drag and drop operation:

  1. //WebElement on which drag and drop operation needs to be performed  
  2. WebElementfromWebElement = driver.findElement(By Locator of fromWebElement);  
  3.   
  4. //WebElement to which the above object is dropped  
  5. WebElementtoWebElement = driver.findElement(By Locator of toWebElement);  
  6.   
  7. //Creating object of Actions class to build composite actions  
  8. Actions builder = newActions(driver);  
  9.   
  10. //Building a drag and drop action  
  11. Action dragAndDrop = builder.clickAndHold(fromWebElement)  
  12.              .moveToElement(toWebElement)  
  13.              .release(toWebElement)  
  14.          .build();  
  15.   
  16. //Performing the drag and drop action  
  17. dragAndDrop.perform();  

36) What are the different methods to refresh a web page in WebDriver?

There are multiple ways of refreshing a page in Webdriver.

1. Using driver.navigate command –

  1. driver.navigate().refresh();  

2. Using driver.getCurrentUrl() with driver.get() command –

  1. driver.get(driver.getCurrentUrl());  

3. Using driver.getCurrentUrl() with driver.navigate() command –

  1. driver.navigate().to(driver.getCurrentUrl());  

4. Pressing an F5 key on any textbox using the sendKeys command –

  1. driver.findElement(By textboxLocator).sendKeys(Keys.F5);  

5. Passing ascii value of the F5 key, i.e., “\uE035” using the sendKeys command –

  1. driver.findElement(By textboxLocator).sendKeys(“\uE035”);  

37) Write a code snippet to navigate back and forward in browser history?

Navigate back in browser history:

  1. driver.navigate().back();  

Navigate forward in browser history:

  1. driver.navigate().forward();  

38) How to invoke an application in WebDriver?

  1. driver.get(“url”); or  
  2. driver.navigate().to(“url”);  

Misc. Questions – Selenium Interview Question.

39) What are the benefits of Automation Testing?

Benefits of Automation testing are as follows.

  • It allows execution of repeated test cases
  • It enables parallel execution
  • Automation Testing encourages unattended execution
  • It improves accuracy. Thus, it reduces human-generated errors
  • It saves time and money.

40) How can we get a text of a web element?

Get command is used to get the inner text of the specified web element. The get command doesn’t require any parameter, but it returns a string type value. It is also one of the widely used commands for verification of messages, labels, and errors,etc.,from web pages.

Syntax

  1. String Text = driver.findElement(By.id(“Text”)).getText();  

41) How to select value in a dropdown?

We use the WebDriver’s Select class to select the value in the dropdown.

Syntax:

selectByValue:

  1. Select selectByValue = new Select(driver.findElement(By.id(“SelectID_One”)));  
  2. selectByValue.selectByValue(“greenvalue”);  

selectByVisibleText:

  1. Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));  
  2. selectByVisibleText.selectByVisibleText(“Lime”);  

  1. Select selectByIndex = new Select(driver.findElement(By.id(“SelectID_Three”)));  
  2. selectByIndex.selectByIndex(2);  

42) What are the different types of navigation commands?

The navigation commands are as follows.

navigate().back()

The above command needs no parameters and takes back the user to the previous webpage.

Example

  1. driver.navigate().back();  

navigate().forward()

The above command allows the user to navigate to the next web page with reference to the browser’s history.

Example

  1. driver.navigate().forward();  

navigate().refresh()

The navigate().refresh() command allows the user to refresh the current web page by reloading all the web elements.

Example

  1. driver.navigate().refresh();  

navigate().to()

The navigate().to() command allows the user to launch a new web browser window and navigate to the specified URL.

Example

  1. driver.navigate().to(“https://google.com”);  

43) How to deal with frame in WebDriver?

An inline frame abbreviates as an iframe. It is used to insert another document within the current document. These document can be HTML document or simply web page and nested web page.

Select iframe by id

  1. driver.switchTo().frame(“ID of the frame”);  

Locating iframe using tagName

  1. driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));  

Locating iframe using index

frame(index)

  1. driver.switchTo().frame(0);  

frame(Name of Frame)

  1. driver.switchTo().frame(“name of the frame”);  

frame(WebElement element)

Select Parent Window

  1. driver.switchTo().defaultContent();  

44) Is there an HtmlUnitDriver for .NET?

To use HtmlUnit first use the RemoteWebDriver and pass it in the desired capabilities.

  1. IWebDriver driver  
  2. new RemoteWebDriver(DesiredCapabilities.HtmlUnit())  

For the Firefox implementation to run, use

  1. IWebDriver driver  
  2. new RemoteWebDriver(DesiredCapabilities.HtmlUnitWithJavaScript())  

45) How can you redirect browsing from a browser through some proxy?

Selenium facilitates with a PROXY class to redirect browsing from a proxy. Look at the example below.

Example

  1. String PROXY = “199.201.125.147:8080”;  
  2. org.openqa.selenium.Proxy proxy = new.org.openqa.selenium.Proxy();  
  3. proxy.setHTTPProxy(Proxy)  
  4.  .setFtpProxy(Proxy)  
  5.  .setSslProxy(Proxy)  
  6. DesiredCapabilities cap = new DesiredCapabilities();  
  7. cap.setCapability(CapabilityType.PROXY, proxy);  
  8. WebDriver driver = new FirefoxDriver(cap);  

46) What is POM (Page Object Model)? What are its advantages?

Page Object Model is a design pattern for creating an Object directory for web UI elements. Each web page is required to have its page class. The page class is responsible for finding the WebElements in web pages and then perform operations on WebElements.

The benefits of using POM are as follows.

  • It facilitates with separate operations and flows in the UI from Verification – improves code readability
  • Multiple tests can use the same Object Repository because the Object Repository is independent of Test Cases.
  • Reusability of code

47) How to capture screenshot in WebDriver?

Below is the program to capture screenshot in WebDriver.

  1. import org.junit.After;  
  2. import org.junit.Before;  
  3. import org.junit.Test;  
  4. import java.io.File;  
  5. import java.io.IOException;  
  6. import org.apache.commons.io.FileUtils;  
  7. import org.openqa.selenium.OutputType;  
  8. import org.openqa.selenium.TakesScreenshot;  
  9. import org.openqa.selenium.WebDriver;  
  10. import org.openqa.selenium.firefox.FirefoxDriver;  
  11.   
  12. public class TakeScreenshot {  
  13. WebDriver drv;  
  14. @Before  
  15. public void setUp() throws Exception {  
  16. driver = new FirefoxDriver();  
  17. drv.get(“https://google.com”);  
  18. }  
  19. @After  
  20. public void tearDown() throws Exception {  
  21. drv.quit();  
  22. }  
  23.   
  24. @Test  
  25. public void test() throws IOException {  
  26. //capture the screenshot  
  27. File scrFile = ((TakeScreenshot)drv).getScreenshotAs(OutputType.FILE);  
  28. // paste the screenshot in the desired location  
  29. FileUtils.copyFile(scrFile, new File(“C:\\Screenshot\\Scr.jpg”))  
  30. }  
  31. }  

48) How to type text in a textbox using Selenium?

The sendKeys(“String to be entered”) is used to enter the string in a textbox.

Syntax

  1. WebElement username = drv.findElement(By.id(“Email”));  
  2. // entering username  
  3. username.sendKeys(“sth”);  

49) How can you find if an element is displayed on the screen?

WebDriver allows user to check the visibility of the web elements. These web elements can be buttons, radio buttons, drop, checkboxes, boxes, labels etc. which are used with the following methods.

  • isDisplayed()
  • isSelected()
  • isEnabled()

Syntax:

  1. isDisplayed():  
  2. boolean buttonPresence = driver.findElement(By.id(“gbqfba”)).isDisplayed();  
  3. isSelected():  
  4. boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isSelected();  
  5. isEnabled():  
  6. boolean searchIconEnabled = driver.findElement(By.id(“gbqfb”)).isEnabled();  

50) How to click on a hyper link using linkText?

  1. driver.findElement(By.linkText(“Google”)).click();  

The above command search the element using a link text, then click on that element and thus the user will be re-directed to the corresponding page.

The following command can access the link mentioned earlier.

  1. driver.findElement(By.partialLinkText(“Goo”)).click();  

The above-given command searches the element based on the substring of the link provided in the parenthesis. And after that partialLinkText() finds the web element with the specified substring and then clicks on it.