Tuesday, August 17, 2021

                                                                              click here for Manual Testing Interview Questions

What is method overload and method override?

Method Overload: Method overload means methods contain with same name and difference in the parameters

This difference may be in the 

-> sequence of the parameters

-> number of the parameters

-> type of the parameters

Method overload is an example of Dynamic Polymorphism/runtime polymorphism

Method Override: Method Override means methods with same name and same parameters. This override performs in parent and child classes

Method override is an example of Static Polymorphism/Compile time Polymorphism


What is a static keyword in Java?

If applies static to the member of a class. You can directly access that with the classname without creating any object.

  • The value of the  static variable is shared by all objects of a class means same set of copy available to all the objects.


What is final keyword in Java?

Final means fixed. No changes can be happened on it. If applies final

    -> to a variable then, that variable value can not be changed.

    -> to a method then, that method can not be override

    -> to a class then that class can not be inherited.


What are the Access Modifiers?

Access Modifiers are:

1. public

2. private

3. default

4. protected

-> public means that member of a class can be visible and accessed anywhere in the project.

-> private means that member can be visible and accessed with in a method or class.

-> default means that member can be visible and accessed with in a package. If no access modifier is used, it considers as default

-> protected means that member can be visible and accessed with in a package and in child classes of another package.


What is Selenium?

Selenium is a automation tool which is used to automate the web applications.

Advantages of Selenium?

1. Selenium is an Open-Source

2. Selenium supports multiple languages like Java, c#, Python, Ruby, Perl etc.,

3. We can write the automation scripts in multiple browsers like chrome, firefox, IE, Microsoft Edge etc.,

4. Selenium supports multiple Operating Systems Windows, Linux, Mac etc.,

5. Supports Android and iOS


What is a WebDriver?

WebDriver is an Interface, it is implemented by respective Browser Drivers like ChromeDriver, FirefoxDriver etc.,


Write a simple Selenium Script or Code?

System.setProperties("webdriver.chrome.driver","Path of the Driver File");

WebDriver driver=new ChromeDriver();

driver.get("URL");


What are different Locators in Selenium?

Locator: Locator means an address of an WebElement. We have Locators in Selenium like

1. id

2. name

3. className

4. tagName

5. linkText

6. partialLinkText

7. xpath

8. cssSelector


What is absolute xpath and relative xpath?

absolute xpath starts with '/' and it identifies the element from route node to child node.

relative xpath starts with '//' and it identifies the element directly where it present in the HTML DOM.

Note: / -> single forward slash, // -> double forward slashes


How to write relative xpath?

We can write the relative xpath in multiple ways one the way is by using tagName, attribute and values like

//tagName(@attribute='value')

Also we can write this  with

1. text() method

2. contains() method

3. xpath axes like parent, ancestor, preceding-sibling and forwarding-sibling etc.,


What is the difference between xpath and css selector?

XPath and CSS Selectors are both used to locate elements on a web page. Some common differences are:

1. Xpaths are expressive. CSS selectors are generally shorter and often easier to read.

2. XPath can traverse up, down, and sideways in the DOM. CSS Selectors can only go down (from parent to child), not backwards.

3. XPath can traverse through siblings. Css Selector can not support siblings.

4. XPath supports text-based functions like text(), contains() and startsWith() etc., CSS Selector doesn't support these text-based functions.

5. Use XPath if you need complex logic. Use Css if you need basic stuff.

6. XPath is slower, CSS Selector is faster.

What is a Page Object?

A Page Object is class which is created for each and every page of an application.

This class contains all the WebElements of the page and getter methods for respective webElements.


What is the PageFacory?

PageFacory is a class which is used to initialize the PageObject.


Diference between findElement and findElements()?

findElement() is used for Single element and return type is WebElement. If no element is found then findElement() returns NoSuchElementFoundException.

findElements() is used for List of WebElements and return type is List<WebElement>. If no element is found then findElements() returns empty list.


What are the waits in Selenium?

Selenium provides waits like

1. implicitwait

2. explicitwait

3. fluentwait


What is the difference between implicit wait and explicit wait?

implicit wait is used to provide waiting time for all the WebElements

explicit wait is used to provide the waiting time for a specific condition or WebElement.


Write a code for implicit wait?

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


Write a code for explicit wait?

WebDriverWait wait = new WebDriverWait(driver,30);

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("locator")));


How to enter the data into the textbox?

We can enter the data into any textbox using 3ways:

1. sendKeys() method from WebElement

2. JavaScriptExecuter

3. Actions class


How to click on a button?

We can click any button using 3ways:

1. click() method from WebElement

2. JavaScriptExecuter

3. Actions class

If a button has submit as attribute-value then we can use directly submit().


How to get the text of a WebElement?

using getText(), we can get the Text.


How to initialize the webdriver?

WebDriver driver =new FirefoxDriver();

Here, we create the object for the class 'FirefoxDriver' and store it in reference variable of the Webdriver Interface.


How to launch a browser and pass the URL?

    1. First, we need to set the property for the driver like

    System.setProperty("webdriver.gecho.driver", "path of the driver file");

    2. Intialize the driver like

    WebDriver driver =new FirefoxDriver();

    3. Use the get() method to pass the URL like

    driver.get("URL");


what is the difference between quit() and close()?

quit() method closes all the window instances opened by the driver

close() method closes only current window instance.


How to handle/select dropdown element in the selenium?

We can handle dropdown element using Select class. The class contains the methods like

selectByIndex()

selectByValue()

selecByVisibleText()

Example: 

Select select=new Select(driver.findElement(By.xpath("locator")));

select.selectByVisibleText();


How to do mouse over action and click()?

We can take the help of Actions class to this. 
1st create an object for actions class
2nd Perform the mouse hover action using moveToElement method.
3rd click on the link using click method and apply build().perform() operation.

Example:
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.xpath("<xpath>"))).perform();
action.click().build().perform()

How to Handle multiple Windows in Selenium?

getWindowHandle(), getWindowHandles() and switchTo() methods help to work with multiple windows.

All Opened window Ids get and store in Set reference variable and switch them with switchTo() method.

How to take a screenshot in Selenium?

We can take the help of "TakesScreenshot" Interface. This interface has the method "getScreenshotAs()". Using this, we can  take the screenshot and save it in a file.

Code Snippet:

    TakesScreenshot scrShot =((TakesScreenshot)webdriver);
    File SrcFile=scrShot.getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(SrcFile, "C:/Test.png");

What is textng.xml file format?

<suite name="SuiteName">

  <test name="TestName ">

      <classes>

      <class name="packagename.classname"/>

      </classes>

  </test>

</suite>


What are different testng Annotations in Order?

@BeforeSuite

   @BeforeTest

      @BeforeClass

         @BeforeMethod

           @Test

         @AfterMethod

      @AfterClass

   @AfterTest

@AfterSuite


@beforesuite -> this annotation will call before executing all the tests

@beforetest -> this annotation will call before executing all test cases

@beforeclass -> this annotation will call before executing all test cases in a class

@beforemethod -> this annotation will call before executing each and every test case

@Test -> it represents a Test Case

@aftermethod -> this annotation will call after executing each and every test case

@afterclass -> this annotation will call after executing all test cases in a class

@aftertest -> this annotation will call after executing all test cases

@aftersuite -> this annotation will call after executing all the tests

What is an Assertion?

Assertion is used for validation. We use Assert class from testng library to this validations. It has methods like assertEquals(), assertTrue(), assertFalse()


How to run only smoke testcases?

We can set the tag in the feature file and it pass in the TestRunner file.


What are the dependecies required for Cucumber BDD Framework?

Along with selenium-java and testng, also require

cucumber-testng

cucumber-java


What are CucumberOptions in TestRunner File?

We have CucumberOptions like

1. features

2. glue

3. tags

4. plugin

5. dryRun

6. monochrome

7. strict

Explanation:

features option is for setting up the path of the feature files

glue option is for setting up the path of the stepDefinition files

tags is to instruct what tag from feature file to execute

plugin is to set which report format to be generate after execution like HTML, JSON, or plain text.

dryRun to check all feature steps has respective matched Step Definition. Default Value is False

monochrome to display console output in readable way. Default Value is False

strict is to fails the execution if there are undefined or pending steps. Default Value is False


What are the Hooks in Cucumber?

Hooks are special functions that run before or after certain event. They execute pre- and post-execution actions, like setting up prerequisites or cleaning up test data, without cluttering the main scenario definitions

Types of Hooks:

Before Hooks: executes before executing each scenario

After Hooks: executes after executing each scenario

Step Hooks: Step hooks are special methods or functions that execute before or after specific Gherkin steps within a scenario.

What are tagged Hooks in Cucumber?

Regular Hooks run before/after every scenario.

Tagged Hooks run only for scenarios with a specific tag.

Ex: 

@Before("@smoke")     // runs only before scenarios tagged with @smoke

public void setupForSmokeTests() {

}

What is the framework you are using and Can you explain briefly?

I am working on BDD Framework with cucumber. It contains the components like

1. feature files

2. stepdefinition files

3. pageobjects

4. testrunner

5. WebDriverManager

6. utility

7. testdata

8. target

9. config folder

10. pom.xml

Can you please explain about each component in the Framework?

feature files -> feature contains scenarios. each scenario is a testcase. 

stepdefinition  file -> 

What is the feature file?

feature file contains all the scenarios to be execute. 

One feature file contains multiple scenarios

One scenario contains multiple steps

We write scenarios and steps in Gherkin Language


What are the Keywords use in feature file?

We use Gherkin Keywords like:

feature at feature level

scenario and scenario outline at scenario level

Given, When, Then, And, But at step level


What is deference between scenario and scenario outline?

we do not pass the testdata in scenario but we can pass testdata in "scenario outline" using "Example" keyword.

Can you write BDD steps for Gmail login Functionality in the feature file?

Yes I write.

with Scenario:

Feature: Application Login

Scenario: Verify Login Functionality

Given I Open The Gmail

When I Entered The Username "abc@gmail.com" and password "12345"

And I Click On Login Button

Then I See Gmail Home Page

or 

with Scenario Outline:

Feature: Application Login

Scenario Outline: Verify Login Functionality

Given I Open The Gmail

When I Entered The <username> and <password>

And I Click On Login Button

Then I See Gmail Home Page

Examples:

      | username | password |

      | abc@gmail.com | 12345 |


What are selenium 4 features?

key features of Selenium 4 are:

1. Selenium 4 introduces relative locators like: above(), below(), toLeftOf(), toRightOf(), and near().

2. W3C WebDriver Protocol Standardization

3. Enhanced Selenium Grid


What is the meaning of build().perform() in Actions class?

When using mouse movements and clicks, build().perform() chains multiple actions together and executes them in sequence.

ex: actions.moveToElement(element1).moveToElement(element2).click().build().perform();









Tuesday, January 5, 2021

 Type Casting:

The process of converting value of one Datatype to another Datatype. Two ways of Casting:

Widening:  Converting a smaller datatype to higher datatype is called widening.

byte-> short -> char -> int -> long -> float -> double

widening happens automatically and it is safe operation. We also call widening as implicit casting.

              Ex:       int n=10;

                          float  x=n;

Narrowing: Converting a higher datatype to smaller datatype is called narrowing.

double -> float -> long -> int -> char -> short -> byte

narrowing happens manually and it is not safe operation. We also call narrowing as explicit casting.

              Ex:       float     n=10.2f;

                          int x=(int)n                  Output: 10

 

Friday, October 16, 2020

What is Smoke Testing?

Smoke Testing: This is build acceptance Testing performed after build is released to the Testing. This Testing is done to check the major functionalities are working fine or not.


What is Sanity Testing?

Sanity Testing: This is build acceptance Testing performed after build is released to the Production. This Testing is done to check the major functionalities are working fine or not.


What is Re-Testing?

Retesting: Retesting is performed after Defect is fixed to verify whether fix is working fine


What is Regression Testing?

Regression: Regression is performed in 3 ways to make sure existing functionality is not disturbed during the changes.

1. Whenever new build is released

2. Whenever a defect is fixed

3. Whenever environment changes are happened


What is UAT?

UAT (User acceptance Testing): UAT is performed verify whether build is acceptable to customer before releasing to the production. We have 2 types of UAT testing:

1. Alpha - Testing

2. Beta - Testing

Alpha-Testing is performed at development site in the presence of the customer

Beta-Testing is performed at production site in the presence of the customer


What is Defect Life Cycle:

Defect Life Cycle: We can say Defect Life Cycle means "the travel of the defect from Open status to Closed status"

There different phases of a Defect:

1. Open

2. In progress

3. Fixed

4. Resolved

5. Closed

6. Reopened

7. Invalid

8. Deferred

-> Whenever a Tester raised the defect, the status of the defect is 'open'.

-> It is moved to "Inprogress" when Developer accepts the defect as Bug

-> When developer gives the fix for the defect then, the status is moved to 'Fixed'

-> Once the defect is fixed, Tester does Retesting. If functionality is working as expected, the status is moved to 'Resolved'

-> If the Functionality is not working as expected, then the status of the defect is moved to 'Re-Opened'

-> All Resolved Defects are moved to the 'Closed' status by the Test Lead.

-> Whenever defect is raised and developer thinks it is working fine. He changes the defect status to 'Invalid'

-> If there are any minor defects and those are not required to fix in the current release the Defect status is moved to 'Deferred' 


What is the deferred status?

If there are any minor defects and those are not required to fix in the current release then, the Defect status is moved to 'Deferred'.


What is Priority and its Levels?

Priority tells How urgency, the defect need to be fixed. It is Client Point of View.

Priority Levels can be:

1. Blocker

2. Critical

3. Major

4. Medium

5. Minor

6. Low


What is Severity and its Levels?

Severity tells the impact of the defect on the application. 

Deferent Severity Levels are:

1. Blocker

2. Critical

3. Major

4. Medium

5. Minor

6. Low


================================================================


What is FileSystem? - Linux
    How to copy a file from one system to another system? - Linux
    How to search a text from a file without Vi editor. - Linux
    

Saturday, March 14, 2020

Variables:

Variable is a name given to a memory location in which, we can store some value which can be used in a program.

Variable Declaration: It is process of specifying what type of data to be stored into the memory location.

              Syntax:     datatype <variable_name>  OR datatype <var1>, <var2>, <var3>

Ex: 

                          int age;  (age is a variable name given to a memory location where we can store integer type of data)

                          float marks;

                          char c;

                          boolean status;

 

1. A Java program can contain any number of variables.

2. In java language, the variable must be first declare then use it. We cannot use the variable without declaring it.

Rules in a variable Declaration:

·         A java program can contain any number of variables

·         The declaration of the variable is dynamic that means we can declare a variable anywhere in a program.

·         The variable in java language must be first declare and use. (java is strongly typed language)

·         When a variable is declared, the memory for that variable is allocated depending upon the data type that is specified

·         Once a variable is declared, the memory for that variable will be allocated and the variable will be automatically initialized with the default value of that corresponding data type.

Data Type                    Default Value            Data Type                     Default Value

  byte                ->                  0                           float                                    0.0

  short               ->                  0                           double                                0.0

  int                  ->                   0                           char                                    space

  long               ->                   0                           boolean                               false

 

              The default data type under integer category is “int”. The default data type under floating point category is “double”.

              If a variable is declared and if we do not provide any value, then that variable will be automatically initialized with the default value.

 

Declaring and Initializing a Variable:

              The variable can be initialized with our own values at the time of declaration.

Syntax:

          datatype <variable_name> = <value>;                     (OR)

          datatype <variable_name1> = value1, <variable_name2> = value2  so on……

Ex:    int a = 12;        OR      int a=10, b=20, c=30;

Initialization: The process of providing a value to the variable for the first time is called a initialization.

Assignment: The process of providing a value to a variable second time onwards is called a assignment.

              The value of a variable can be changed during the execution of a program that a variable can be assigned any number of times but variable can be initialized only one time.

              Ex:       int a=10;          // Initializing

                          int a=20;          // Assigning

Note: We can also call a value as a literal.

                          int a = 10;                    // 10 is integral literal

                          float b = 12.2               // 12.2 is floating point literal

                          char c = ‘$’                  // $ is character literal

Method: A method is a block of code that perform some task or an action.

JVM executes a method only when we call or invoke it.

We write a method once and use it many times. We do not require to write code again and again.

A method must be declared within a class.

A method can be called any number of times.

Method Creation Syntax:

              <access specifier> <return type> <method name>(parameters list){

            //Method body

}



Example of Method Creation:

public void addition(int a, int b) {

           System.out.println(a+b);

}

A method contains Two parts. Method Header and Method Body. Method header contains 4 components those are access specifier, return type, method name and parameters.



Monday, July 29, 2019


       WebDriver drivernew FirefoxDriver();
                  (vs)
       FirefoxDriver drivernew FirefoxDriver();

WebDriver -> is an Interface
FirefoxDriver, ChromeDriver, IEDriver -> are classes

All the abstract methods of Webdriver interface are implemented in RemortWebDriver class which is extended by browser classes such as FirefoxDriver, ChromeDriver etc.,

In the above first statements we are creating objects for the browser class and casting it to WebDriver interface reference variable. 
In the statement FirefoxDriver driver =  new FirefoxDriver();,
The FirefoxDriver instance which gets created will be only able to invoke and act on the methods implemented by FirefoxDriver.. Using this statement, we can run our scripts only on Firefox Browser

To act with other browsers we have to specifically create individual objects as below:
ChromeDriver driver =  new ChromeDriver();
InternetExplorerDriver driver =  new InternetExplorerDriver();

To achieve we go for 
WebDriver driver =  new FirefoxDriver();
Whenever object is creating for the browser class and casting it to same driver reference variable
It helps you when you do testing on multiple browsers.
This is happening in dynamically run time. So that we can dynamic Polymorphism is applying here.
Question: How do you check whether a table data(values) is sorted or not? Sorting happens when clicking on Table Header(Ex: Name, which is a link).
Name
Venu
Avinash
Dharma
Answer:
We can take an array of String type as expected values and consider the column values which need to be verify are as actual values. Which can be resolved by below example.


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CompareTwoLists {
       public static void main(String[] ar){
              List<String> expdValues = new ArrayList<String>();
              expdValues.add("venu");
              expdValues.add("avinash");
              expdValues.add("dharma");
              Collections.sort(expdValues);     //to arrange given list in sorting
             
              List<String> actValues = new ArrayList<String>();
              actValues.add("dharma");
              actValues.add("venu");
              expdValues.add("avinash");
              Collections.sort(actValues);
             
              if(expdValues.equals(actValues)){
                     System.out.println("Given Lists are Matched");
              }else{
                     System.out.println("Given lists are not matched");
              }
       }
}



Selenium Training in Realtime

Blog helps to a student or IT employee to develop or improve skills in Software Testing.

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *