Tuesday, December 8, 2020

How to set M2 path ans install Maven on macOS Catalina v 10.14.XX

 On previous mac Operating systems we just download the Maven and add path to .bash_profile file inside the user path.

That's because when we open a terminal from mac it opens a bash type of terminal as on the below image.



But with the latest macOS bash type terminals are no longer available.

Now we have zsh type of terminals.


There for even you add paths to .bash_profile Maven is not going to work.

So you have to edit .zshrc file inside your users folder.




So locate the .zshrc file or if not create a new file and add below lines to the .zshrc file.(As you normally do with .bash_profile file).

export M2_HOME=/Users/<your profile name>/Documents/Data/apache-maven-3.6.3
export PATH=$PATH:/Users/<your profile name>/Documents/Data/apache-maven-3.6.3/bin

Thursday, October 22, 2020

Copying Rest API command from Postman is not working in C# RestSharp? Here is the fix!

 As we all know if we click on the code button as on the image we can convert the Postman command to any sort of programming language.




Here are some languages we can convert the code.


But if you directly copy and past the code for C#-RestSharper then your code might not work.

There won't be any exceptions, But you will not get the response that you are expecting.

It always returns NULL response.


To make it work you have to do some adjustments.

Below is the original code and just comment the highlighted line which is  request.AddHeader("Connection", "keep-alive");



Actually to get this code work you need to add "using RestSharp" to your C# code.

Other thing is no need to add all these headers to get a valid output, You can simplify the above code by only having below lines.

request.AddHeader("Authorization",....);

request.AddHeader("Content-Type", "application/json");




Monday, August 3, 2020

How to change IP address time to time from selenium C#


  1.  [TestMethod]
  2.         public void ChromOptions()
  3.         {

  4.             string[] proxies = { "206.198.131.142:80", "51.81.112.164:5836" };

  5.             for (int i = 0; i < proxies.Length; i++)
  6.             {
  7.                 ChromeOptions options = new ChromeOptions();
  8.                 options.AddArguments("--proxy-server="+proxies[i]+"");
  9.                 driver = new ChromeDriver(@"C:\ChromeDriver1\", options);
  10.                 driver.Navigate().GoToUrl("https://whatismyipaddress.com/");

  11.             }
  12.         }

Above is a C# code to switch your browser IP.
At line 5 you have to give a list of working proxy IP and the PORT list as an array.

Thats it.

Sunday, June 21, 2020

How to move files from all the sub directorys to another which dont no the directory name

I had an issue where I need to move some files from one folder to another folder but the challenge was the source folder name get change time to time.
Basically the folder name will be a random GUID.

So I was unable to stick to a simple windows batch command because I don't n know the exact source folder name where my files available.

So this is a simple solution for that.
Just download the below EXE file and pass the arguments as it shows.

Basically what it does was extract everything from subfolders (what ever the sub folder name) on a given folder and place them on another folder.

https://drive.google.com/file/d/1v-JbHRvzXdfpMYfpZoAvEetLx2Bdzi4E/view?usp=sharing

MoveFiles.exe "source folder where your files stay" "Target folder where you want to move the files" "what kind of file extensions you need to move"

MoveFiles.exe "C:\Development\XXX\XXX" "C:\Development\XXX\XXX"  "*.XXX"


Thursday, June 18, 2020

Dotnet Code Coverage for SonaQube

It's not that much hard.
If you are with dot net 2.0 or above then just execute the below command on your test project location.

(where the XXX.Test.csproj available.)

1).dotnet test --collect "Code Coverage"

Then the tests will get to execute and at last there will be a coverage file available as on the test result folder.

Attachments:
  C:\Program Files (x86)\Jenkins\workspace\Backend Dev\test\Api.Test\TestResults\88de1678-d457-4e6c-a3fd-2d5786cddc13\ar0_2020-06-18.10_24_43.coverage
Total tests: 132. Passed: 66. Failed: 57. Skipped: 9.
Test Run Failed.
Test execution time: 44.3640 Seconds

Then convert the .coverfile to coveragexml file using below command.

2).CodeCoverage analyze /output:VisualStudiot.coveragexml  ar0_2020-06-18.10_24_43.coverage

You can use below nuget command to download the CodeCoverage packages.

dotnet add package Microsoft.CodeCoverage --version 16.6.1


The just point the newly created coveragexml file to sonar server by below code.

3).sonar.cs.vscoveragexml.reportsPaths=C:/Development/VisualStudiot.coveragexml

Thursday, May 28, 2020

How to open browser windows one by one with Jmeter selenium

I had this issue with me when I'm working on a project.
Because When I set thread count to 100 it will open 100 browsers and the CPU and other resource utilization going up.
So unfortunately server will get hang.

I have post the same issue in https://sqa.stackexchange.com/ but still I didn't get any proper solution.

So I start my own to find a solution.
Then I found

You have to download below plugin to J meter.
https://jmeter-plugins.org/wiki/ConcurrencyThreadGroup/


  • Add the bzm - Concurrency Thread Group.
  • Set the parameters as on the image.
  • So it will run for a couple of hours without eating your server resources.

While its running you can do your other work.


Sunday, January 12, 2020

[FIX] The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required.

I got above error when i try to send my test results at the [AssemblyCleanup] step on my automation test suite.
This is how my code looks like.

 public static void SendEmail()
        {

            string fromAddress = "@gmail.com";
            string mailPassword = "";
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
            SmtpServer.Port = 587;
            SmtpServer.EnableSsl = true;
            SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
            SmtpServer.UseDefaultCredentials = false;
            SmtpServer.Credentials = new System.Net.NetworkCredential(fromAddress, mailPassword);
          

            MailMessage myMail = new System.Net.Mail.MailMessage();
            myMail.From = new MailAddress("xxxx@gmail.com");
            myMail.To.Add("xxxx");
            myMail.To.Add("xxxx");

            myMail.Subject = " Test Results";
         
            String body = "Test Status";
            myMail.IsBodyHtml = true;
            myMail.Body = body;
            myMail.Attachments.Add(new Attachment(@"..\..\..\xx\Reports\xx.html"));


            SmtpServer.Send(myMail);

        }

But still Im getting the above error so the solution was to enable Less secure app access by navigating to below URL
https://myaccount.google.com/u/3/lesssecureapps?pli=1&pageId=none

Then update your Gmail password to a very strong password.

Wednesday, January 8, 2020

WebDriver Wait - IMPLICIT & EXPLICIT

IMPLICIT - suggested though not directly expressed - Not the best practise.

driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.


EXPLICIT - stated clearly and in detail - The best practise.

in some cases, if any element is taking too much time to be visible on the software web page then you can use EXPLICIT WAIT condition in your test case.