Uncategorised

Database interview questions

database, Uncategorised
Question 1: SQL Query to find second highest salary of Employee Answer: There are many ways to find second highest salary of Employee in SQL, you can either use SQL Join or Subquery to solve this problem. Here is SQL query using Subquery: Select MAX(Salary) from Employee WHERE Salary NOT IN (select MAX(Salary) from Employee ); SELECT max(salary) FROM Employee WHERE salary < (SELECT max(salary) FROM Employee); See How to find second highest salary in SQL for more ways to solve this problem. Question 2: SQL Query to find Max Salary from each department. Answer : SELECT DeptID, MAX(Salary) FROM Employee  GROUP BY DeptID. Question 3: Write SQL Query to display current date. Answer: SQL has built in function called GetDate() which returns current timestamp. SELECT GetDate(); Q

Finding links in Selenium

Uncategorised
HOW TO GET TOTAL NO OF LINKS ON WEB PAGE? How to get total no of links on Web page? Step to follow… 1) Navigate to the interested webpage for e.g. http://newtours.demoaut.com/ 2) Create a list of type WebElement to store all the Link elements in to it. 3) Collect all the links from the webpage. All the links are associated with the Tag ‘a‘. 4) Now iterate through every link and print the Link Text on the console screen. package pack2; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class Program1 { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get("http://newtours.

Zoom in and Zoom out Page in selenium

Uncategorised
Though such scenarios are not common in automation activities, you may encounter need to simulate browser zoom operation. These scenarios are common if you need to carry out accessibility testing. In this tutorial, we have implemented Selenium zoom example with Java’s Action class. Zoom In and Zoom Out operations are carried out by ‘CTRL +’ and ‘CTRL – ‘ key press respectively. We will simulate these commands in Selenium WebDriver using Action class. Commands for those are Keys.chord(Keys.CONTROL, Keys.ADD) and Keys.chord(Keys.CONTROL, Keys.SUBTRACT). Similarly for zooming back in to the default level, Keys.chord(Keys.CONTROL, “0”) command is used. To apply zoom on web page, we need to reference it with its HTML tag by using driver.findElement(By.tagName(“html”)) code. Now, let

Selenium Introduction

Automation, Level1, Selenium, Uncategorised
Selenium Introduction: What is Automation Testing Benefits of Automation Testing When to automate an application: Steps to follow in Automation testing: Disadvantages of Automation Testing Different Automated Web Testing Tools Selenium Introduction Selenium Pros Selenium Cons Differences between selenium and other Tools What is Automation Testing? The Process of converting Manual Test cases into Test Script by using any automation tool is known as Automation Testing. Testers write test scripts and test cases using the automation tool and then group those test cases into test suites. Benefits of Automation Testing Reliable: Tests perform precisely the same operations each time they are run, thereby eliminating human error Repeatable: You can...

Handle Proxy in Selenium

Uncategorised
How to Handle Proxy in Selenium WebDriver Most of the time when we create any WebDriver automation code using public websites like Google, Facebook, Yahoo… etc, which works very well at our home pc but not at office. This may have various reasons. One of the reasons is PROXY at your office network. What is Proxy? A proxy or proxy server is basically another computer which serves as a hub through which internet requests are processed. By connecting through one of these servers, your computer sends your requests to the proxy server which then processes your request and returns what you were wanting. In this way it serves as an intermediary between your home machine and the rest of the computers on the internet. Proxies are used for a number of reasons such as to filter web con

Selenium Webdriver Architecture

Uncategorised
Before starting the automation using any automation tool, it is very important to know how that tool works and how it is architecture. This will helps to take the good advantage of the tool at the same time it will helps to make right automation framework. At a very high level, Selenium is a suite of three tools. Selenium IDE is an extension for Firefox that allows users to record and playback tests. The record/playback paradigm can be limiting and isn’t suitable for many users. Selenium WebDriver provides APIs in a variety of languages to allow for more control and the application of standard software development practices. *An application programming interface (API) is a particular set of rules (‘code’) and specifications that software programs can follow to communicate with

Handle Untrusted Certificate Selenium

Uncategorised
What is Untrusted SSL certificate?  » Whenever We try to access HTTPS website or application so many time you will face  untrusted SSL certificate issue. This issue comes in all browser like IE, Chrome, Safari, Firefox etc. Why we get this certificate issues often? This certificates some in multiple conditions and we should know all of them so that we can rectify them easily. 1- Each secure site has Certificate so its certificate is not valid up-to-date. 2– Certificate has been expired on date 3– Certificate is only valid for (site name)  4- The certificate is not trusted because the issuer certificate is unknown due to many reasons. Handle Untrusted Certificate Selenium Step 1-We have to create FirefoxProfile in Selenium. Step 2- We have some predefined method in Sel

Dependency Test in TestNG

Uncategorised
Dependency Test in TestNG Sometimes, you may need to invoke methods in a Test case in a particular order or you want to share some data and state between methods. This kind of dependency is supported by TestNG as it supports the declaration of explicit dependencies between test methods. In simple, Dependency means if one @Test method fails or skipped from execution then its dependent @Test method must not be executed. TestNG allows you to specify dependencies either with: Using attributes dependsOnMethodsin @Test annotations OR Using attributes dependsOnGroupsin @Test annotations. Take a look over the below example: package TestNgAdv; import org.testng.Assert; import org.testng.annotations.Test; public class SetPriority2 {@Test(priority = 1) public void Lo

Expected Exception and Expected Message in TestNG

Uncategorised
Expected Exception and Expected Message in TestNG While writing unit tests there can be certain scenarios where we need to verify that an exception is being thrown by the program during execution or not. TestNG provides a feature to test such scenarios by allowing the user to specify the type of exceptions that are expected to be thrown by a test method during execution. It supports multiple values being provided for verification. If the exception thrown by the test is not part of the user entered list, the test method will be marked as failed. Let’s create a sample test and learn how exception test works in TestNG. @Test ( expectedExceptions = { IOException.class, NullPointerException.class } ) Let’s see an example to understand it better. In below test, we ha

TESTNG ANNOTATIONS FOR SELENIUM

Uncategorised
Annotations are nothing but a piece of instruction for the compiler that you apply to classes, methods or variables in your Java code. It is a powerful feature and an integral part of the TestNG framework. There are multiple TestNG annotations which you can use for different tasks. It is essential to know each of the annotation so that you could apply them correctly while working on a TestNG Selenium WebDriver project.  Let’s see what the TestNG annotations for Selenium WebDriver are and what is their objective? The TestNG annotations extend the same concept and control the execution sequence of the test code and test methods. I’ve drilled down the list of primary TestNG annotations along with a little detail about each of them. TestNG Annotations Description @Test