Monday, January 31, 2022

Setup Allure in Windows 10 and Generate Allure Report

  1. Download the latest allure framework from the below link - https://github.com/allure-framework/allure2
  2. Set the allure bin path
  3. Open the CMD and check the allure version by entering 'allure --version'
  4. Run the test cases
  5. Open the CMD and run the following command to generate the allure report - 'allure serve D:\Learnings\Project\build\allure-results'
  6. Automatically the report will be opened


To run a cucumber test using Gradle -
.\gradlew.bat test --tests RunTests




Thursday, January 6, 2022

How to set the generated token as an Environment Variable in Postman Tool

Generated Token Response -

{
    "data": {
        "authToken": {
            "getToken": {
                "accessToken""b1hXMCJ9.eyJhdWETQ1NTk2NSwiYWlvIjoiCJhcHBpZCI6IjQ1ZTMA"
            }
        }
    }
}

Use the below code snippet to set the generated token as an environment variable in Postman Tool

Paste the below code in the Test tab (Please modify the code according to your response).
Environment Variable: token (Use this variable across the API's)

Example: In headers - Authorization : {{token}}


var responseObject = JSON.parse(responseBody);

if (responseObject && responseObject.data && responseObject.data.authToken && 
responseObject.data.authToken.getToken  && responseObject.data.authToken.getToken.accessToken)
{
    postman.setEnvironmentVariable("token"`Bearer ${responseObject.data.authToken.getToken.
                                                            accessToken}`);
}

Thanks for watching this space.

Tuesday, December 7, 2021

How to install Cypress on windows machine -

1. Download and install node.js

2. Open the cmd and type npm --version to check the npm version and type npm init.

3. After the initialization, Go to your project folder and Type 'npm install cypress --save-dev'

4. Wait for the installation to complete.

5. Cypress will be installed in your project folder (Cypress has now been installed in your ./node_modules directory, with its binary executable accessible from ./node_modules/.bin.)

6. Delete the cypress file from ./node_modules/.bin

7. Verify the cypress by using npx cypress verify.

8. To open the cypress, type cypress open and wait for a few seconds, the cypress application will be opened.


Kindly adhere to the following instructions to utilize the most recent edition:

  1. Acquire and install node.js.
  2. Launch VS code.
  3. Establish a new project.
  4. Activate the terminal and execute the subsequent commands to install the required components:

  • npm init -y
  • npm install cypress
  • npm install -D typescript
  • npm run cypress:open


Thursday, November 18, 2021

 

How to Click a button or links from browser console window by Using JQuery


var y = 0;
while( y < 2 ) 
    $x("//a[@class='wsmc-topmenu__breadcrumb-link--home']")[y].click();
    y = y + 1;
}

Result: 
Two times, the link or button will be clicked.

Try this solution and result is awesome.

Monday, July 19, 2021

Get most recent folder and move the files from one computer to another computer using batch commands

@echo off
FOR /F "delims=" %%i IN ('dir /b /ad-h /t:c /o-d') DO (
    SET a=%%i
    GOTO :found
)
echo No subfolder found
:found
echo Most recent subfolder: %a%

mkdir "\\DEE\AT\Files\%a%"
XCOPY %a% \\DEE\AT\Files\%a% /s /h /Y
pause 

Wednesday, April 14, 2021

How to get text from parent element and exclude text from children (C# Selenium)

Example: Suppose you have the following DOM

<h2 class="title">Charger

<div class="default"> 

<span>method</span> 

<span class="sr-only">Default</span>

</div> 

</h2>


<h2 class="title">Mobile

<div class="default"> 

<span>method</span> 

<span class="sr-only">Default</span>

</div> 

</h2>


<h2 class="title">Cable

<div class="default"> 

<span>method</span> 

<span class="sr-only">Default</span>

</div> 

</h2>

Solution: You can use the below code to fetch the parent element texts (i.e. Charger, Mobile and Cable) IList list = Application.driver.FindElements(By.XPath("//h2")); string[] texts = new string[list.Count]; foreach (IWebElement element in list) { texts[i] = (string)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].firstChild.textContent;", element); i++; } return texts;

Friday, December 25, 2020

How to get the number of objects created in JAVA

Program to get the number of objects created in JAVA

public class Main

{

    static int i=0;

    public Main()

    {

        i++;

    }

    public Main(String name)

    {

        i++;

    }

public static void main(String[] args)

{

    Main m=new Main();

    Main m1=new Main("Balaji");

    System.out.println(i);

}

}

Output:

2