Posts

Showing posts from November, 2024

Automation testing in Postman

Image
 Common API status code: 1. 200 - request was successful 2. 201 - record has been created successfully 3. 204 - no content  4. 400 - bad request 5. 401 - unauthorised 6. 403 - forbidden 7. 404 - not found 8. 429 - too many request 9. 500 - server error 10. 501 - internal server error 11. 503 - time out ------------- In postman, we can use the snippet packages written in javascript such as below: Below is a sample of how to run an automation test in Postman for API testing This will be checking the specific value of a variable Creating, storing and using a variable in Postman storing in an environment invoking the variable in a different API (must select the correct environment) Checking the first returned id data: If need to run the full collection: Test result:

API & Webservice

Image
  Difference between webservice and API - All webservice are APIs - APIs might not be a webservice Examples of API terms POST: create a record GET: read or view a single or multiple records PUT: update an existing record DELETE: delete an existing record Can use below site for testing: Reqres - A hosted REST-API ready to respond to your AJAX requests

XPath, Test data variables on Specflow

Image
 XPath is not a very reliable element to use for automation especially in start up projects as there would be a lot of changes. (e.g. if developer change the position of the element) XPath syntax: Example of self-written XPath: Example 2: A more stable way to create XPath: Good practice for recognizing element: 1. Always use ID if available as they are unique 2. Name 3. Class - if class is unique 4. use text 5. copy paste XPath ------------- Test Data variables on Specflow: *There must be method that could check and assert the variables here.

Specflow Pt2, using different test data

Image
  In the step definition, just input the codes respectively. string here indicates that this method will return a string value. If void would mean that there is no value to be returned. This will be the validation and testing portion for specflow Description here will be a variable. All data below Description are the test data to be used during testing. Underlined in red would be a dynamic value. Underlined in yellow is the variable parameter. EditTM method needs to be updated to accept a description parameter.

Specflow, Gherkin

Image
 Specflow is a BDD framework - purpose of using Specflow is when you want to apply BDD methodology (because Selenium is not enough to implement BDD) BDD Behavior-driven development (BDD) is an agile software development methodology that  focuses on collaboration and communication between developers, testers, and business stakeholders Selenium is also a framework NUnit is also a framework In feature file part, will use Gherkin syntax to write test case (will only include human language test case) Step definition will bridge the human language with the code To use Specflow, need to install below NuGet packages Creating a feature file: Folder > Add > New Item > Specflow The tag can be used to tag the test case. Example, @positive / @smoke / @regression etc What is Gherkin ? Given, When, Then - These are Gherkin syntax Creating the step definition:

IAlert, Flaky test, Tear Down, parallelizable

Image
  To accept an alert: ----- Flaky test - means a code that fails to produce the same result each time Tear Down: To make independent tests able to be run parallelly

Unit Testing - NUnit, assertions, exception handling

Image
 Why unit test is useful? Example if we have 100 tests, and you just want to run test number 25 and 40. This is where you can make use of unit test. What is a unit test? Unit test is essentially a framework. A framework is a pre-defined structure that provides a starting point for building software.  It includes reusable code modules, libraries, compilers, and other components There are many frameworks to do unit testing such as Nunit, Xunit etc. What is a design pattern? Design pattern is how you structure your tests. How your code is presented in your solution. Example, you have test class, and then pages and codes are inside the pages etc.  NUnit Annotations: - SetUp - Test - TearDown - TestFixture Not commonly used: - OneTimeSetUp - OneTimeTearDown NuGet Packages Microsoft.NETCore.App is the package that allows to run tests as a dot net core application. This is essentially a framework. For NUnit testing, to install below NuGet packages: NUnit package allows us to use...

Implicit, explicit and fluent wait - Selenium (C#)

Image
  Difference between Wait and Sleep - In sleep, the code will just wait for the full amount of time specified, example 10000ms, the code will wait for 10000ms - In wait, the code will wait for the full amount of time specified or until the condition specified are met whichever comes first.  Example: If you tell the code to wait 10000ms or until it finds a clickable element, if it can find the clickable element in 2000ms, it will proceed to the next step. WebDriverWait class is under Selenium support UI package Implicit wait example: WebDriverWait wait = new WebDriverWait(driverName, TimeSpan.FromSeconds(7)); //this means that the code will wait for 7 seconds Explicit wait example: WebDriverWait wait = new WebDriverWait(driverName, TimeSpan.FromSeconds(7)); wait.Until(ExpectedConditions.ElementExists(By.Id("id"))); //this means wait 7 seconds or until the element exists whichever is earlier To use DotNetSeleniumExtras.WaitHelpers to use ExpectedConditions class public static v...

GitGUI

Image
  Click commit Then click Push Successfully pushed

Creating new folder & classes in VS (Selenium - C#)

Image
Creating new folder in VS Creating new class within VS folder To change to public class     This will allow us to use this class from anywhere within the project

Switching action to web alerts - Selenium, C#

Image
 

Initializing chrome driver Selenium - C#

Image
  To bypass an overlapping element

Synchronisation issue with Selenium

Synchronisation issue with Selenium Sometimes when we run our code, Selenium cannot find the element even when we know that that element is there. Why does this happen? The webdriver is slower than actual code. What if when we go to url and we open the page, what happens when it doesn't load yet but the code is already at the next step trying to find the element. So to fix this issue, we can use the thread sleep or wait functionality.

Test Automation tool, VS, selenium, Github, Gitbash

Image
 Test Automation tool - Selenium WebDriver (can use C#, java, phyton, etc - Cypress with JavaScript - Playwright Which tool should be used? - no dependency on what devs used to develop the code What is a gitignore file? When we push our code into github, the different extension files will not be pushed into our repo. That is what the gitignore file is for. Once we have created a repo, we need to clone it into our local. What is gitbash for? - can be used for cloning ------------------- Visual Studio - Visual studio is like a mobile phone - want to access FB What do we need to start FB? Need to download the FB app. Since now we wanna use Selenium, we have to download Selenium into VS. This is what we call Nuget Package (similar to FB app in terms of mobile phone) Nuget Package manager is similar to an App Store - Selenium webDriver nuget package will allow us to access the Selenium library of codes - Selenium Support will provide support classes for selenium GitBash Means I am on th...

DevOps, Github

 Dev Ops Manual Example: Team gonna build login functionality of a software team: 3 Developers, tester, system engineer 1 dev for FE, 1 dev for DB, 1 dev for BE working in parallel They will discuss what they are gonna use and how they are gonna approach this particular task - Dev 2 will create framework for project and upload in Github in a repository - thereafter, Dev 3 will copy whatever that has been uploaded on Github and start to work on that file  - this allows all 3 devs to work on the same version at the same time - once dev 3 finish, he will push the code to the repository and inform other devs - before the dev 1 and 2, push his or her code into Github, they need to merge the code of dev 3 and then push their latest changes to Github - once development is done and all pushed to Github, dev will inform system engineer - system engineer will grab all that code and deploy it to the test environment for the tester to start testing - it was then decided that 10 out of 50 ...

Functional vs non-functional test

  Functional Test vs Non-Functional Test - Examples of functional Test     - System test     - integration test     - end to end test - Examples of non-Functional Test     - load testing     - Security testing     - usability testing     - compatibility testing     - basically the different conditions the software is put under