Thursday 7 March 2024

Reverse A String In Java | Program To Reverse A String | Reverse String In Java | [Simple and Easy]

In today's video, I will be showing you how to reverse a string in Java! ► Software Used: ● IntelliJ IDEA: https://www.jetbrains.com/idea/download/ Learn how to reverse strings in Java effortlessly.

Monday 11 December 2023

API Testing tutorials 1 - Idempotency, Safe, Cache and Versioning Concept

We are going to understand some of the important Concepts in rest API for sample example I have added a screenshot from Postman which is a popular API testing.

Concept in rest API

we are going to cover four important concepts like:

  • Idempotency
  • save
  • cache 
  • versioning
Let us understand the first concept idempotency:
Idempotent methods can be called multiple times with same input, and it produces same result.
example if we are having a get request and we are hitting it multiple times then we are going to get same result so what we can say get is idempotent.

I have talked about these concepts in detail in this video:


Sunday 3 September 2023

TestNG Tutorial #9 Before Test and After Test in TestNg

@BeforeTest: This will be executed before the first @Test annotated method. It can be executed multiple times before the test case. @AfterTest: A method with this annotation will be executed when all @Test annotated methods complete the execution of those classes inside the <test> tag in the TestNG. xml file.

Watch this video to understand more:

Wednesday 23 August 2023

TestNG Tutorial #10 Before Class and After Class in TestNg Automate Myntra


@BeforeClass: The annotated method will be run before the first test method in the current class is invoked. @AfterClass: The annotated method will be run after all the test methods in the current class have been run. @BeforeMethod: The annotated method will be run before each test method.

Watch this video to understand more:

Friday 11 August 2023

#8 The @BeforeTest methods run after each Test methods in testNg

The @BeforeTest methods run after each Test methods. @BeforeTest can be used for creating an initial data set up and prior to running other test methods, whereas @AfterTest annotation will run after the other tests are complete.

Watch this video to understand more:

Thursday 10 August 2023

TestNG Tutorial #7 running tests parallel in TestNg using XML file

What Is TestNG.Xml?

TestNG.xml file is a configuration file that helps in organizing our tests. It allows testers to create and handle multiple test classes, define test suites and tests.

It makes a tester’s job easier by controlling the execution of tests by putting all the test cases together and run it under one XML file.

Major advantages of TestNG.xml file are:

  • It provides parallel execution of test methods.
  • It allows the dependency of one test method on another test method.
  • It helps in prioritizing our test methods.
  • It allows grouping of test methods into test groups.
  • It supports the parameterization of test cases using @Parameters annotation.
  • It helps in Data-driven testing using @DataProvider annotation.
  • It has different types of assertions that help in validating the expected results with the actual results.
  • It has different types of HTML reports, Extent reports, etc. for a better and clear understanding of our test summary.
  • It has listeners who help in creating logs.
Watch this video for deep understanding of testNg

Friday 28 July 2023

TestNG Tutorial #6 Managing Test Execution using TestNg XML files

What Is TestNG.Xml?

TestNG.xml file is a configuration file that helps in organizing our tests. It allows testers to create and handle multiple test classes, define test suites and tests.

Major advantages of TestNG.

It provides parallel execution of test methods. It allows the dependency of one test method on another test method. It helps in prioritizing our test methods. It allows grouping of test methods into test groups.


Refer the video on how to use testNg.xml

Sunday 1 January 2023

TestNG Tutorial #5 Include and exclude methods in Appium, Selenium

TestNg provides an option to include or exclude Groups, Test Methods, Classes and Packages using include and exclude tags by defining in testng.xml.

First we will create an examples to use include and exclude tags for Test Methods in a class.

We will create a Class with three Test Methods. In that we will include two test methods and try to exclude one test method.

Watch below video to understand how to use it:

Monday 31 October 2022

TestNG Tutorial #3 How to use Hard Assertion in Selenium TestNg


In this video we are going to see what is hard assertion in testng


 

Hard Assertion

The Default build mechanism of assert is Hard assertion, and it’s stored in org.testng.assert package. We use this type of assertion when our requirement for the test execution should stop immediately is the assertions fail and will throw an assertion error. The test case also marked as failed when a hard condition fails.

Example:

package com.techbeamers.hardassertion;
import org.testng.Assert;
import org.testng.annotations.Test;
public class HardAssertion 
{
   String className = “HardAssertion”;

   @Test
   public void test_UsingHardAssertion() {
      Assert.assertTrue(true == true);
      Assert.assertEquals(“HardAssert”, “HardAssertion”);
      Assert.assertEquals(className, “HardAssertion”);
      System.out.println(“Successfully passed!”);
   }
}
...
FAILED: test_UsingHardAssertion
java.lang.AssertionError: expected [HardAssertion] but found [HardAssert]
...

Tuesday 9 August 2022

Appium| Locator strategies | Find elements in Native App Android, iOS

Locator strategies supported by Appium:

In the video we will see how to find element in different os Android and iOS when doing mobile automation testing:
ID Class Name Xpath Accessibility ID Android UI Automator Android View Tag (Espresso Only) iOS UI Automation


Refer part 2 here: https://mobiletestingtip.blogspot.com/2021/11/appium-locator-strategies-2-find.html

Tuesday 7 June 2022

Appium: Tap gesture using Touch Action Class

Appium: Tap gesture using Touch Action Class

While the Selenium WebDriver spec has support for certain kinds of mobile interaction, its parameters are not always easily mappable to the functionality that the underlying device automation (like UIAutomation in the case of iOS) provides. To that end, Appium implements the new TouchAction / MultiAction API defined in the newest version of the spec (https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html#multiactions-1). Note that this is different from the earlier version of the TouchAction API in the original JSON Wire Protocol. These APIs allow you to build up arbitrary gestures with multiple actuators. Please see the Appium client docs for your language in order to find examples of using this API. Note for W3C actions W3C actions is also available in some drivers such as XCUITest, UIA2, Espresso and Windows. W3C actions are implemented to the best of the limitations of the operating systems' test frameworks. e.g. WDA cannot handle zero wait PR. API doc and API docs of each client help to understand how to call them. An Overview of the TouchAction / MultiAction API TouchAction TouchAction objects contain a chain of events. In all the appium client libraries, touch objects are created and are given a chain of events. The available events from the spec are: * press * release * moveTo * tap * wait * longPress * cancel * perform



Sunday 8 May 2022

TestNG Tutorial #2 - How to Write Test Cases Using TestNG

How to write first test case in TestNg 
In this video we are going to see
  1. Setting Up A TestNG Project In IntelliJ?
  2. First Test Case With TestNG Downloading Selenium Jar Files For TestNG using maven 
  3. How To Create A TestNG Test Class In TestNG?

Saturday 8 January 2022

TestNG Framework introduction with intelliJ IDE | Setup Environment

Introduction to TestNG

From the the TestNg official site: TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing (testing a class in isolation of the others) to integration testing (testing entire systems made of several classes, several packages and even several external frameworks, such as application servers).

Writing a test is typically a three-step process:

  • Write the business logic of your test and insert TestNG annotations in your code.
  • Add the information about your test (e.g. the class name, the groups you wish to run, etc...) in a testng.xml file or in build.xml.
  • Run TestNG.
You can find a quick example on the TestNg Welcome page.

The concepts used in this documentation are as follows:

  • A suite is represented by one XML file. It can contain one or more tests and is defined by the <suite> tag.
  • A test is represented by <test> and can contain one or more TestNG classes.
  • A TestNG class is a Java class that contains at least one TestNG annotation. It is represented by the <class> tag and can contain one or more test methods.
  • A test method is a Java method annotated by @Test in your source.
A TestNG test can be configured by @BeforeXXX and @AfterXXX annotations which allows to perform some Java logic before and after a certain point, these points being either of the items listed above.

The rest of this manual will explain the following:

  • A list of all the annotations with a brief explanation. This will give you an idea of the various functionalities offered by TestNG but you will probably want to consult the section dedicated to each of these annotations to learn the details.
  • A description of the testng.xml file, its syntax and what you can specify in it.
  • A detailed list of the various features and how to use them with a combination of annotations and testng.xml.


Friday 5 November 2021

Appium| Locator strategies -2 | Find elements in iOS using iOSClassChain & iOS Predicate String Strategy

iOS Class Chain Strategy

This query type is WebDriverAgent's layer over native XCTest lookup function calls defined in XCUIElementQuery class with some additional features, like intermediate chain items indexing and tail-based indexing. Search by direct children and descendant elements is supported.


The final option is a sort of hybrid between XPath and predicate strings: the -ios class chain locator strategy. This was developed by the Appium team to meet the need of hierarchical queries in a more performant way. The types of queries possible via the class chain strategy are not as powerful as those enabled by XPath, but this restriction means a better performance guarantee (this is because it is possible to map class chain queries into a series of direct XCUITest calls, rather than having to recursively build an entire UI tree). Class chain queries look very much like XPath queries, however, the only allowed filters are basic child/descendant indexing or predicate string matching. It’s worth checking out the class chain docs to find a number of examples. Let’s take a look at just a couple:

iOS Predicate String Strategy

Predicate queries are natively supported by XCTest and enable the quick location of elements based on their attribute values.

Follow the rules described in Predicate Format String Syntax article.

Predicate Format Strings are a typical Apple dev thing, and they also work in iOS. Predicate format strings enable basic comparisons and matching. In our case, they allow the basic matching of elements according to simple criteria. What’s really useful about predicate strings is that you can combine simple criteria to form more complex matches. In the XCUITest driver, predicate strings can be used to match various element attributes, including name, value, label, type, visible, etc…


Watch the full video to understand how you can make use of the iOS Class chain and iOS predicate string to get rid of XPath completely.


Reference:




Friday 1 October 2021

How to Install Java JDK on MacOS with JAVA_HOME Step by Step installation



Download Java SDK on Mac


Open Terminal -) java -version

Serach for oracle java sdk

open the first link

choose JDK download

select macOS installer 

Download the JDK .dmg file here: http://www.oracle.com/technetwork/java/javase/downloads/index.html


Install the SDK for Mac

  • Double click the .dmg file.
  • Double click the package icon to launch the Install app.
  • Click Continue.
  • Click Install.
  • Enter the administrator user name and password and click Install Software.
  • After the software is installed, delete the .dmg file so that you can save disk space.




If The .zshrc file is not present by default in macOS Catalina, So you may need to create it. Additionally you can also use ~/. bash_profile or ~/.profile if they are present to store your java variable


Steps for creation:

  1. Open Terminal
  2. Type touch ~/.zshrc to create the respective file. (touch command will create the .zshrc in your current directory but it will be hidden)
  3. Hit Return

To view/open ~/.zshrc you can do either of two things:


  1. Open Finder -) Press Cmd+Shift+.

Or:

  1. I will use Open Terminal -) and type: open ~/.zshrc

- If using bash_profile use: open ~/. bash_profile

- If using .profile  use: open ~/.profile 



export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home"


source ~/.zshrc



Thursday 9 September 2021

Create AVD virtual device using Android studio and install APK

 How to Create New AVD (Virtual Device) In Emulator in Android Studio and Install Apk


We start AVD in Emulator to test our Android App. AVD Manager is basically a tool that you can use to create and manage AVD (Android Virtual Devices) for the Android Emulator. It is also called Emulator.


  1. OPEN Android Studio Select Tools -> Android -> AVD Manager -> Click the AVD Manager icon in the toolbar. You can also open AVD Manager directly by clicking the AVD icon in the Toolbar.
  2. Android Virtual Device Manager will be opened. After that Click on Create Virtual Device.
  3. After that choose the Category, phone size and choose the pixels according to your requirement. After this click on the Next button.
  4. After that choose the SDK Version and Click on the Next button. If you have various SDK Versions like 11, 12 and 10 etc in your SDK then you can select one of them. 
  5. Enter the AVD Name in Android Virtual Device and click on the Finish button. Here you can do customization to AVD which you are creating as per your requirement.Click Finish and a new AVD will be created.
  6. Now again open AVD manager and you will see your newly created AVD (Android Virtual Device) is added to the list.Click to Start the Virtual Device green play button
  7. After that, your AVD will start in Emulator. Now you can run your App in this AVD.

    Drag and drop the app from System to Simulator to install it.
Look below video to understand the whole process in detail:


Tuesday 17 August 2021

Commonly asked selenium interview questions - Part 1




Commonly asked selenium interview questions I will keep updating the list.

I have added the answer along with the questions but feel free to comment below if you feel there are any better answers or there can be more questions that can be added.

 

1.     Write xpath using contains keyword : //h3[contains(text(),'Health Testing')]

 

  1. Difference between Interface and abstract class: 

In Java, abstraction is achieved using Abstract classes and interfaces. Both contain abstract methods which a child class or implementing class has to implement. Following are the important differences between abstract class and an interface. An abstract class permits you to make a functionality that subclasses can implement or override whereas an interface only permits you to state functionality but not to implement it. A class can extend only one abstract class while a class can implement multiple interfaces.

  1. Which one follows 100% abstraction: 

Interfaces

 

  1. What are the different types of collections used? 

Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet).

 

  1. String abc = "My name is saif" find saif

// Java program to demonstrate working

// contains() method

class Gfg {

 

// Driver code

public static void main(String args[])

{

String s1 = "My name is GFG";

 

// prints true

System.out.println(s1.contains("GFG"));

 

// prints false

System.out.println(s1.contains("geeks"));

}

}

 

  1. Difference between implicit and explicit wait: 

Implicit waits are used to provide a default waiting time between each consecutive test step/command across the entire test script. ... Explicit waits are used to halt the execution until the time a particular condition is met or the maximum time has elapsed.

 

  1. Different desired capabilities in Selenium?    getBrowserName():,setBrowserName(),getVersion(),setBrowserName()

 

  1. How to use extent report:      

ExtentReports is an open-source reporting library useful for test automation. It can be easily integrated with major testing frameworks like JUnit, NUnit, TestNG, etc. These reports are HTML documents that depict results as pie charts. They also allow the generation of custom logs, snapshots, and other customized details. Once an automated test script runs successfully, testers need to generate a test execution report. While TestNG does provide a default report, they do not provide the details

 

  1. Why we use listeners :

As the name suggests, Listeners possess the ability to “listen” to a certain event. Often used for customizing reports and logs, it serves as an interface that can modify system behavior.

 

  1. @BeforeTest vs @BeforeMethod

@BeforeTest: It will call Only once, before Test method. @BeforeMethod It will call Every time before Test Method.

 

  1. We have two class in each class we have two test annotations how many times before test and after test run will run and how many times before and after method will work.

            Before Test and after test two time and before method and after method test     4 times

 

  1. If the priority is not set for test how it will run?

If you don’t mention the priority, it will take as “priority=0” for all the test cases and execute. Lower priorities will be executed first. If we define priority as “priority=” for multiple test cases, then these test cases will get executed only after all the test cases which don’t have any priority and set priority to 0 as the default priority

 

  1. Tell me something about yourself, your current company, and current project?

            Answer here: https://youtu.be/roxO0X_k9EU

14.  Explain the different exceptions in Selenium WebDriver,chrome,firefox,iOs driver android driver: Though there are many Exception classes under WebDriverException, we commonly see the below ones;

·       NoSuchElementException

·       NoSuchWindowException

·       NoSuchFrameException

·       NoAlertPresentException

·       InvalidSelectorException

·       ElementNotVisibleException

·       ElementNotSelectableException

·       TimeoutException

·       NoSuchSessionException

·       StaleElementReferenceException

 

 

  1. What is a page object?

Page Object is a Design Pattern that has become popular in test automation for enhancing test maintenance and reducing code duplication. A page object is an object-oriented class that serves as an interface to a page of your AUT.

 

  1. How to scroll down a page using JavaScript in Selenium?

jse.executeScript("scroll(0, 250);");

We can scroll down a page by using window.scrollBy() function.

 

16.  Dependsonmethod: dependsOnMethods : 

dependsOnMethods attribute on a test method [test1 e.g.] specifies all the test methods [test2, test3,..] this test method depends on. It means test1 will start execution only after all the tests it depends on executed successfully.

 

  1. Synchronization technique: 

all waits

  1. What type of reports you have worked on

The above classes can be used with the frequently used built-in methods that are stated below.

·       startTest

·       endTest

·       Log

·       flush

startTest and endTest methods are used to execute preconditions and post-conditions of a test case, while log method is used to log the status of each test step onto the resultant HTML report. Flush method is used to erase any previous data on the report and create a new report.

Test Status can be any of the following values:

·       PASS

·       FAIL

·       SKIP

·       INFO

Syntax:

reports.endTest();

test.log(LogStatus.PASS,”Test Passed”);

test.log(LogStatus.FAIL,”Test Failed”);

test.log(LogStatus.SKIP,”Test Skipped”);

test.log(LogStatus.INFO,”Test Info”);

 

  1. Write a program to reverser string

// Java praogram to illustrate the

// java.lang.StringBuffer.reverse()

import java.lang.*;

 

public class Test {

 

public static void main(String args[])

{

StringBuffer sbf = new StringBuffer("Geeksforgeeks!");

System.out.println("String buffer = " + sbf);

 

// Here it reverses the string buffer

sbf.reverse();

System.out.println("String buffer after reversing = " + sbf);

}

}

 

19 - create xpath find element before any element?


20 - run same test cases multiple time

            TestNg has one method.

            @Test(invocationCount = 100)

 

 

 Here is the Appium Playlist for beginners:  Appium


 

 

 

 

Interview Experience with AMAZON for the role of Quality Assurance Tester

This role was for Digital/ IoT/Mobile Application based testing :)  Amazon is a dream company and everyone wants to work for that company a...

Popular Posts