Creating a shortcut key to paste certain texts on any editor

Lately, I have been interviewing a lot of candidates and had to send “ONE’ email to multiple recipients (read recruiters) to extend the meeting invite for the interviews. I was tired of sending the same email multiple times in a day where I had to attach the CV and put in a message to extend the invite to the candidate. Since attaching the document had to be unique so I did not bother about it but typing or copying the same text every time and pasting it on my email editor was a real pain.

I thought of automating it to get rid of this redundant activity and finally got hold of a solution that has started working now. Its called “AutoHotKey“.

Requirement: I wanted to create a shortcut key using which a paragraph is pasted or autocorrected. AutoHotKey came to the rescue which you can download from https://www.autohotkey.com/. Once you have downloaded the latest version, right click on your desktop and click on New > AutoHotKeyScript > A editor opens up > You provide the shortcut key and the exact paragraph that you want in below format:

Please put in your text and shortcut in the AutoHotKey Script file like shown below:

Save this file and run it by double clicking on the file

You would see the below text getting auto corrected when you type in the shortcut key


“Hi There,

Please extend the invite to the vendor partner/candidate and keep us informed about the acceptance.

Regards,

Santosh

This utility is going to save quite some time for me whenever I have to send this invite to the recruiter with a cv attached, the time saving would not be very substantial but peace of mind and ease to hand would definitely be helpful for me.

Hope it would help you as well in automating any small or big redundant task that you currently might be doing on a daily basis. I am pretty sure that this utility will have more to provide than I quoted here but I have just started. Please let me know if you have any such problem statements and I can try helping you.

Happy Testing!

Santosh

Getting rid of the annoying credential pop up in Visual Studio

If you are using Visual Studio and are tired of seeing the credential pop up which keeps on asking the credential, please stay with me. I have struggled a lot and the worst part is no matter how many times you keep on closing the pop up, it keeps reappearing and doesn’t give you breathing time when you can restart the Visual Studio instance. The only workaround is to end the task from task manager but that definitely solves the problem at hand and it reappears again when you open Visual Studio:

Have a glance at the pop up I am talking about here:

Enough of the story now, this keeps happening whenever there is a restore failure that happens when you start the Visual Studio. You can tackle this problem by following below step:

Close the Visual Studio instance through the task manager

Open the project directory and search for Nuget.exe file

Once located, copy the file and paste it in the location where you have the solution file

Now, open the command prompt as an administrator and navigate to the path where you copied Nuget.exe in previous step

Run the below command

nuget.exe restore YourSolution.sln

Wait for the restore to happen through the CLI and now you are all set to open your solution in Visual Studio without this annoying pop up.

-PS: I am sure there must be other workarounds but I felt like posting this since nothing worked out in my case and this worked like a charm.

Thank you for stopping by!.

Happy Testing

Santosh

Creating feature files on your local Notepad ++

At times, we as automation testers must connect to a remote VM to develop our test scripts in BDD. This is mostly due to the organization policy that one cannot have the source code on their local machine. It is also observed that it is quite a heavy operation to open the IDE and load the entire solution where you just need to design a Gherkin with let’s say one scenario in a separate feature file. To make this process lighter, we can develop our scenarios on our local using Notepad ++. By default, Notepad ++ doesn’t identify the Gherkin language so a UDL is needed. This UDL is actually developed by a BDD pioneer named ‘Andy Knight’ who owns a very famous and successful BDD blog at https://automationpanda.com/

Steps to enable Notepad ++ to consider the GHERKIN language:

  • Download the ‘gherkin_npp_udl.xml’ file from https://github.com/AndyLPK247/automation-panda-resources
  • Open Notepad++ on your local and click on Languages menu > Define a Language > Import the downloaded file
  • Save the file as ‘.feature’ and try writing your first feature file on your notepad using the GHERKIN language and it should now provide you the correct indentation and color coding.

This might look like a trivial thing when you start to use it but believe me while working with a big team having multiple development VM’s where test scenarios were written, this quick tip of writing/designing the feature file on your local and then moving it to the solution on your VM might help to save some good amount of time.

Reference: https://automationpanda.com/2017/01/18/gherkin-syntax-highlighting-in-notepad/

Tagged , , , , ,

History of BDD cut short

I am assuming you have navigated to this article to learn few historical facts about BDD, I am putting in some below:

BDD might be one of the most talked about topic I the last few years while either hiring automation resources or laying down the automation test strategy for projects, programs or, organizations, but let me tell you the idea of such implementation was put in long back in 2003 by ‘Daniel Terhorst-North’. The idea of BDD came from another utility called ‘Agile Dox’. Agile Dox was a utility that was supposed to remove the word ‘test’ from the methods and functions in a class.

public class CustomerLookupTest extends TestCase {   testFindsCustomerById() {

    …   }     
testFailsForDuplicateCustomers() {
    …   
}   …
}

renders something like this:

CustomerLookup
– finds customer by id
– fails for duplicate customers – …

The word “test” is stripped from both the class name and the method names, and the camel-case method name is converted into regular text. That’s all it does, but its effect is amazing.

Out of this utility, the following points have been understood that led to the discovery of BDD as we call it now:

  • Having the name of the “tests” expressed correctly could help
  • Behavior was more useful and understandable for the three amigos and could be used for documentation.

Once the above two facts were noted and understood, Daniel started working towards creating JBehave for Behavior from Junit. It was realized that BDD could provide a ubiquitous language for analysts and that’s when Gherkin was thought through incrementally. Gherkin language was invented across two major increments as shown below:

As a [X]                                                           
I want [Y]
so that [Z]

Given some initial context (the givens),
When an event occurs,
then ensure some outcomes.

References: https://dannorth.net/introducing-bdd/

Security Test of REST API’s using SOAP UI

REST API’s can be tested from the security perspective, using SOAP UI as a tool. Few of the advantages and disadvantages are listed below:

ADVANTAGES:

  • Functional test cases of the API can be used as it is for security testing
  • Flexibility to add scripts, strings etc in the repository which you want to pass through as a parameter in the URL or the HTTP request
  • You can track the failure of the test cases using the Console for the test run

DISADVANTAGES:

  • There is no way to automatically crawl the API methods and run the pre-defined security tests like XSS Attack, SQL Injection etc.
  • There is no direct way to generate reports for the security tests performed with the basic version of SOAP UI. The Pro edition has reporting capabilities

STEPS TO VALIDATE A REST API’s METHOD WITH DIFFERENT SECURITY TESTS:

Assumption: If you are running security tests on any of the methods in REST API’s controller, you must have a referring document where you would see which all parameters the request take and what is the expected response. For e.g., see the below screenshot:

S1

From the screenshot above, we can derive the following about the method of the API under test:

  • The name of the method is saveSurvey() which saves the definition of the survey
  • The method takes clientID, surveyID and request body as the parameter
  • Not that it is mentioned in the document correctly, but clientID is a query parameter and parameters like surveyDefinition and openSurveyForParticipants are not needed. These need to be updated in the document. You can ignore them for now
  • The saveSurvey() method deals with a PUT request and consumes media type as application/json
  • You also the key value pairs which you can expect in the response once the PUT request is hit using SOAP UI

Pre-requisite: The API is hosted on a server and can be accessed using a correct port.

Now, say the API is hosted on ‘testMachine001’ on port 9005, the base URL to access the API will be http://testMachine001:9005 and we can pass the parameters as per the document.

Follow the below mentioned steps to run a security test on the PUT method discussed above in the document:

  • Create a REST project say ‘SecurityTestofRestAPI’sMethod’ in SOAP UI

S2

  • Now, you would see the Request1 window. Change the Method to ‘PUT’ and provide an endpoint to access the API hosted
  • Add the 2 parameters viz. clientID and surveyDefID. For now, we are directly providing a value here but we can use property transfer feature of SOAP UI to get these values coming from previous requests
  • Provide the body of the request as mentioned in the document for the API
  • On the right pane of the Request window, select JSON as this is the format we are expected our response.
  • Please refer to the screenshot on below to ensure that you made the changes correctly

S3

  • Once the request is ready, add it to the test suite and then to the test case as shown in the screenshot below:

S4

S5

  • Once this request is added as a test case, you would see an option for Security Tests right below the Test Case
  • Right click on it and add a new security test case as shown below:

S6

  • From the Security test case window, add the different types of security tests you want to perform on this request as shown in the screenshot below:

S7.JPG

  • For the demo, we would add Cross Site Scripting from the list as our security test, once added, add the assertions and parameters you want to add so that SOAP UI keeps passing scripts and junk values as a value to your request parameters defined in the request

S8

  • If you want to test for cross site scripting of the request under test with any of your custom scripts, you can add them from the below screen:

S9.JPG

  • Now, your first security test for one of the methods of the API is ready and you can execute the test by clicking on the run icon. You can see the log from the Security Log tab on how your request parameter is getting attacked for XSS using different scripts pre-defined in SOAP UI plus the custom one you added
  • Once the test runs successfully, you can see if it found any issues there from the below screenshot

S10

  • If you want to see where exactly the alert was generated, you can traverse back to the Security Log and find the same unless we have reporting capability in the free version of SOAP UI

Please leave a comment if you have any problem in running your first security test using the SOAP UI

Initializing Browsers in Selenium

We need an utility to drive our tests, we call it the Driver. In Selenium, browsers are the test driver and as we have multiple browsers, we might need multiple drivers(viz. Firefox, Internet Explorer, Chrome etc.) to ensure that the testable item works fine in all the supported browsers.
Today, we would be covering on the very basic and initial process of downloading and using all the three drivers as mentioned above. So, let’s start with Firefox, this driver is provided with the Selenium package, for others, we need to separately download them and use the executable file to drive our tests.

What needs to be done to use Firefox Driver with Selenium?

First of all, make sure that your Java project has ‘Selenium Server’, ‘Selenium-Java’ and ‘Selenium-Firefox-Driver’ jars downloaded on your machine. Add all these jars to your build path so that the project could use the classes and hence the methods and data members defined within the class.
You can use any of the IDE to create your java project, I used Eclipse, but you could also use IntelliJ etc. Once the Java project is created and the build path is properly configured, create a class in the java project which by default would have main() method in it. For now, unless we go into advance topics like TestNG etc, lets stick to the main() and try initializing the Firefox driver from there. Find below the code to initialize the Firefox driver

import org.openqa.selenium.firefox.FirefoxDriver;

public class TestClassDemo {

public static void main(String args[]){

FirefoxDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
}

}

For Chrome and Internet Explorer :

Ensure that the executable files for Chrome and IE are downloaded and stored in some location on your computer.
Now, for Chrome use the following code:

System.setProperty(“webdriver.chrome.driver”,
chromeDriverLocation);
// Settings for browser logs
DesiredCapabilities caps = DesiredCapabilities.chrome();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.SEVERE);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

driver = new ChromeDriver(caps);

Similarly, for IE, use the following code:

System.setProperty(“webdriver.ie.driver”, ieDriverLocation);
// Settings for browser logs
DesiredCapabilities caps = DesiredCapabilities
.internetExplorer();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.SEVERE);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
driver = new InternetExplorerDriver(caps);

If you face any trouble in using any of the code sample, feel free to write to me at srivastava367@gmail.com or add a comment here, I would get back to you ASAP.

 

Thanks and happy testing!!
SK Srivastava

Design a site like this with WordPress.com
Get started