Posts

Showing posts from September, 2020

REST API Method

GET -  Gets a resource POST -  Creates a resource PUT - Updates the record. (User needs to send entire JSON with the field to be updated) PATCH - Updates the record. But user does not have to send entire JSON in request url DELETE -  Deletes a resource

Rest API Testing fundamentals

Image
 What is an API?  An API can be defined as an Interface that takes requests from a Client system to a web server and sends back the response from a Web server to the client machine. Definition 2: An interface that facilitates communication between Client machine and a Web Server. Example 1: MakeMyTrip.com which aggregates flight information from various airlines and presents it on the website. When user enters information like date, source and destination the request is made to APIs of different Airline companies which then return the information about availability and price. Another example is Trivago which requests the APIs of different Hotels which then returns back information about price and availability of rooms. Example 2,  Let us consider that you are browsing through the products on Amazon.com and you see a product/deal that you really like and you wish to share it with your Facebook network. The moment you click on the Facebook icon on the share section of the page and ente

How to use TesNG with Maven? OR How do call TestNG.xml from Maven?

Image
The maven-surefire plugin is used to call testNG.xml file from maven as follows: Add maven-surefireplugin from maven repository to POM.xml under build/<plugins> add the path to testng.xml file  <configuration>/<suiteXmlFiles><suiteXmlFile> as follows: Run as Maven test will run the testng.xml

How to create a new Maven Project?

Image
 In Eclipse: Click on File>>New Project>> Select Maven Project>> Click Next>>Select "Create a simple project" option>>Following screen will be displayed: A project with following project structure will be created in eclipse:

super keyword in java

Image
 

this keyword in Java

Image

Difference between String s = "text"; and String s = new String("text");

Image
 

TestNG Listeners - ITestListeners

Image
 

Listeners in Selenium

Image
 

Difference Between driver.findElement() and WebElement.findElement()

Image
 

Challenges/Disadvantages of Selenium

Image
 

Interview questions asked in 2020

 1. What is localiztion and globalization testing. 2. What is a data driven framework and Keyword driven framework?What are the differences? 3. Methods used in REST API Testing? (GET, POST, DELETE) 4. Defect life cycle 5. Give an example where a bug can be said as invalid? 6. Explain automation framework. 7. Which type of framework did you use? 8. Difference between Keyword driven and Data driven framework 9. How do you prioritize test cases in testNG? 10. How do you run only selected test cases in testNG (Without using groups) 11. What if a developer says that it is not a bug? what will you do? Ans: Escalate this to Product owner. 12. How do you switch back to the first tab in selenium. RAI Advisory Interview questions: 1. Click on a button in an Iframe 2. Explain the package structure of you project. 3. Types of Waits in selenium 4. What if you land on a page and using selenium driver.get() and it shows an error popup saying the site is not secure..How will you handle this scenario?

Reading data from CSV files

Image
   Reading data from a CSV File: Before Starting to Understand how to read data from a CSV file let us understand the basics of how to read data from a file. The classes that we need are BufferedReader and FileReader class: https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html https://docs.oracle.com/javase/7/docs/api/java/io/FileReader.html 1. FileReader Class: The file reader class is used to read a file as a stream of chars. The FileReader Class extends the Reader Class. If you want to read a file as a stream of bytes you can use InputStream but reading as stream of bytes is very slow.  File reader reads data from a file as a stream of characters, i.e one character at a time which can be of any byte size The  Java   BufferedReader  class,  java.io.BufferedReader , provides buffering for your Java  Reader  instances. Buffering can speed up IO quite a bit. Rather than read one character at a time from the underlying  Reader , the Java  BufferedReader  reads a larger bl

The 7 principles of Software Testing

  The 7 Principles of Software testing 1. Exhaustive testing is not possible Exhaustive testing, which is also known as complete testing, occurs when all the testers in your team are exhausted and when all the planned tests have been executed. It is a quality assurance testing technique in which all scenarios or data is tested for testing. In a more understandable way, exhaustive testing means ensuring there are no undiscovered faults at the end of the test phase. Testing everything (all combinations of inputs and preconditions) is not feasible except for trivial cases. As testers, we often say “well I just never have enough time for testing”. Even if you had all the time in this world, you still wouldn’t have enough time to test all the possible input combinations and output combinations.   Instead, we need the optimal amount of testing based on the risk assessment of the application. And the million dollar question is, how do you determine this risk? To answer this let's do an ex

What is WebDriver?

    Interviewer: What is a WebDriver? --public interface WebDriver extends SearchContext -- Yes, WebDriver is an interface which represents an “idealised web browser” - it can be chrome/firefox/IE/etc. Why interface? Because every browser has their own logic to perform actions such as launch, close, load URL, handling web elements, etc. Same operations are performed in different ways by different browsers. Considering browser changes, it’s difficult to manage if implemented at WebDriver level. Therefore, WebDriver is built as an interface which consist of all basic methods which could be performed on a browser - and then implemented by respective browser drivers. Methods: close() | findElement(By by) | findElements(By by) | get( java.lang.String  url) | getCurrentUrl() | getPageSource() | getTitle() | getWindowHandle() | getWindowHandles() | manage() | navigate() | quit() | switchTo() Implementing Classes: ChromeDriver, EdgeDriver, EventFiringWebDriver, FirefoxDriver, InternetExplorerD

What is Cyclomatic complexity?

   https://www.tutorialspoint.com/software_testing_dictionary/cyclomatic_complexity.htm

How to scroll in Selenium?

  Answer: One cannot scroll in selenium, for that you have to use JavaScriptExecutor class: 1.Using scrollBy method in JavaScriptExecutor:     main(){                                    System.setProperty("webdriver.chrome.driver", "C:\\Users\\Krunal.Kadu\\Desktop\\Krunal\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://practice.automationtesting.in/"); JavaScriptExecutor js = (driver)JavaScriptExecutor; // cast driver to jsexecutor type                                                                                     js.executeScript("arguements[0].scrollBy(0,250);",driver.findElement(By.xpath("//div/input[1]")));                } 2. Using scrollIntoViewMethod in JavaScriptExecutor:     js.executeScript("arguements[0].scrollIntoView(true);",driver.findElement( By.xpath("//div/input[1]"))); Interview Question: Suppose I land on a page but the Webdriver is trying to find an elemen

Group By in SQL

Group By statement is SQL is used to group rows that have same values into summary rows like "Find the number of Customers in each country" Group by is used by aggregate functions like MIN(), MAX(),SUM(),AVG(),COUNT() to group the result set by one or more columns Eg., SELECT Country, COUNT(CustomerID) FROM Customers GROUP BY COUNTRY; Result: India 10,000 US   5000 China 2000 GROUP BY Example with JOIN: SELECT S.ShipperName, COUNT(O.OrderID) FROM ShipperTable S LEFT JOIN Orders O on S.ShipperId=O.ShipperId GROUP BY S.ShipperName;

Difference between NOW() and CURRENT_TIME() in SQL?

  NOW() is used to show Current date with timestamp of the server while CURRENT_DATE only shows today's date.

Difference between CHAR and VARCHAR is SQL

  CHAR  is used to store a character string of fixed size. CHAR Uses Static memory allocation i.e. if length 10 is defined and the character string size is 6 then, still the variable will hold 10 characters in memory. VARCHAR  is used to store character string of variable size. Varchar uses dynamic memory allocation i.e. only the memory corresponding to the character string length will be occupied. Eg., CREATE TABLE Account( Id Integer, UserName char(10), City varchar ); INSERT INTO Account VALUES (1,"Krunal","Pune"); SELECT LENGTH(UserName) FROM Account where id=1; Output:-  10 SELECT LENGTH(City) FROM Account where id=1; Output:-  4

Java Database Connectivity

Image
   Code:

HashMap in java

  Since  Map  is an interface you need to instantiate a concrete implementation of the  Map  interface in order to use it. The Java Collections API contains the following  Map  implementations: java.util.HashMap java.util.Hashtable java.util.EnumMap java.util.IdentityHashMap java.util.LinkedHashMap java.util.Properties java.util.TreeMap java.util.WeakHashMap   - Hashmap does not guarantee any order of its elements TreeMap  also maps a key and a value. Furthermore it guarantees the order in which keys or values are iterated - Only Objects Can Be Inserted Only Java objects can be used as keys and values in a Java Map. In case you pass primitive values (e.g. int, double etc.) to a  Map  as key or value, the primitive values will be auto-boxed before being passed as parameters. Here is an example of auto-boxing primitive parameters passed to the  put()  method: map.put("key", 123); The value passed to the  put()  method in the above example is a primitive  int . Java auto-boxes i

Test driven framework using TestNG

Image
  

TestNG HandMade Notes

   How To Install Test NG: - Go to TestNG.org - Click on eclipse - Copy the link give on the page: https://dl.bintray.com/testng-team/testng-eclipse-release/ - Go to Eclipse >> Click help >> select install new software >> paste the url in "Add with" box >> click on Add >> Finish ============ # All TestNG annotations: https://www.softwaretestingmaterial.com/testng-annotations/ ============ # Normally to run a java class you need a main method. But when u run TestNG.xml it runs without the java compiler # Adding testNG.xml to a project Right click on project >> Click on TestNG >> Convert to TestNG ======== #Hierarchy of TestNG.xml file: <suite name="Regression Suite"> <test name= "UI validations"> <classes> <class name="tests.BasicsDay1"/> </classes> </test> </suite> ========= # How to exclude a method from test execution without removing or commenting

How to get current date in java?

Image
   Code: The following code displays date time in default format: To get date in desired format, we can use SimpleDateFormat class in Java as follows: Output: