Skip to main content

Posts

Postman: Parse XML and response data value verification using the cheerio library

How to parse XML and validate the response fields using the cheerio library in postman? Sample URL :  https://www.w3schools.com/xml/tempconvert.asmx Sample Request Payload : <soap12:Envelope xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd=" http://www.w3.org/2001/XMLSchema " xmlns:soap12=" http://www.w3.org/2003/05/soap-envelope ">     <soap12:Body>         <FahrenheitToCelsius xmlns=" https://www.w3schools.com/xml/ ">             <Fahrenheit>108</Fahrenheit>         </FahrenheitToCelsius>     </soap12:Body> </soap12:Envelope> Expected Response : <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap=" http://www.w3.org/2003/05/soap-envelope " xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd=" http://www.w3.org/2001/XMLSchema ">     <soap:Body>         ...

Cucumber interchangeable keywords

  Did you know that following keywords are interchangeable in cucumber, but should be better use depending on the context of your flow? Feature | Ability | Business Need Scenario Outline | Scenario Template: Examples | Scenarios #bdd   #cucumber   #syntax   #keywords   #tips   #automation   #gherkin

NPM: peer dependency is not detected for global packages

  Issue : In npm, peer dependency is not detected for global packages like when you try to install "newman" and then install "newman-reporter-htmlextra" so that you can run Postman/Newman tests collection with htmlextra reporter, it keeps failing because no suitable Newman version is found: npm install -g newman npm install -g newman-reporter-htmlextra newman run "Publish.postman_collection.json" -e QAUS.postman_environment.json -r htmlextra --reporters cli,junit,htmlextra  --reporter-htmlextra-export TestReport.html You may get this error: "npm WARN newman-reporter-htmlextra@1.20.4 requires a peer of newman@^5.1.2 but none is installed. You must install peer dependencies yourself" Solution : Peer dependency and the required package should be installed together like:  npm install -g newman newman-reporter-htmlextra

Docker restart policy and how to start containers automatically

 Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts.  Note * If you use docker stop or docker kill, it is expected that Docker does not restart the container. In case of docker stop or docker kill, its restart policy is gong to be ignored until the Docker daemon restarts or the container is manually restarted.  Container restart policy : Container restart policy controls the restart actions when Container exits. Following are the supported restart options: no – This is default. Containers do not get restarted when they exit. on-failure – Containers restart only when there is a failure exit code. Any exit code other than 0 is treated as failure. unless-stopped – Containers restart as long as it was not manually stopped by user. always – Always restart container irrespective of exit status. The following example starts a "selenium/node-chrome" container and configures it to always restart unless it...

Encode/Decode the variable/response using Postman itself

We get a lot of use cases where we may have to implement Base64 encoding and/or decoding while building our APIs. And, if you are wondering if it is possible to encode/decode the variable/response using Postman itself or how to encode/decode the token or password in postman and save it in a variable? To Base64 encode/decode, the quickest way is to use JavaScript methods btoa, atob: atob - It turns base64-encoded ASCII data back to binary. btoa - It turns binary data to base64-encoded ASCII. Sample code : var responseBody = pm.response.json(); var parsedPwd = JSON.parse(atob(responseBody.password)); // presuming password is in the payload pm.collectionVariables.set("password", parsedPwd);

Best place to add code for taking Screenshots with Selenium and Java

  If your UI automation code takes screenshot on failure in test method or page method, then it’s not good. We should handle that using a listener Or have a base class containing AfterMethod annotation that captures screenshots on failure. Use lateral approach (i.e. base class with afterMethod) if you aren’t using listeners in your framework. Go through this well explained article by Alex Siminiuc for more details: https://levelup.gitconnected.com/the-good-the-bad-and-the-ugly-of-taking-screenshots-with-selenium-and-java-c9da23e09842

Making SOAP Requests with Postman

  Even after following what is mentioned here: https://learning.postman.com/docs/sending-requests/supported-api-frameworks/making-soap-requests/ i.e., set Content-Type = text/xml in the Headers and setting POST as a call, at times we get 500 internal server error or bad request with the message like " error message: The message with Action '' cannot be processed at the receiver... " So, what are we missing here? Setting SOAPAction in Headers is worth giving a try... How do we get that? 1. Open your WSDL in a browser with the service URL appended by “?WSDL" and find soapAction for which you want to execute your SOAP call. Like for the "Add" method in http://www.dneonline.com/calculator.asmx?WSDL , soapAction should be set to http://tempuri.org/Add 2. Copy the value of soapAction attribute of your SOAP method. Add a new key, provide Key as “SOAPAction” and the value that you copied in the above step i.e., http://tempuri.org/Add 3. Set “Content-Type” hea...