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