<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gaurav Jani</title>
    <description>The latest articles on DEV Community by Gaurav Jani (@bitwisebro).</description>
    <link>https://dev.to/bitwisebro</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F920585%2F56804751-8384-4276-91a1-f69ef32d9415.png</url>
      <title>DEV Community: Gaurav Jani</title>
      <link>https://dev.to/bitwisebro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bitwisebro"/>
    <language>en</language>
    <item>
      <title>Playwright's LocatorHandler: Simplifying Web Testing and overlay handling</title>
      <dc:creator>Gaurav Jani</dc:creator>
      <pubDate>Wed, 06 Mar 2024 13:13:00 +0000</pubDate>
      <link>https://dev.to/bitwisebro/playwrights-locatorhandler-simplifying-web-testing-and-overlay-handling-33gb</link>
      <guid>https://dev.to/bitwisebro/playwrights-locatorhandler-simplifying-web-testing-and-overlay-handling-33gb</guid>
      <description>&lt;p&gt;Ever feel like a whack-a-mole when unexpected elements like cookie consent popups disrupt your Playwright tests? You're not alone. These overlays can block actions and make tests unreliable. But fear not, Playwright's addLocatorHandler comes to the rescue, offering a streamlined solution to handle these interruptions effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is addLocatorHandler?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Introduced in Playwright version 1.42, addLocatorHandler provides a mechanism to dynamically handle overlays that appear during automated testing. These overlays, like cookie consent dialogs, can block automated actions such as clicking buttons or filling out forms, making tests unreliable and cumbersome to maintain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The addLocatorHandler method allows you to define a custom function that is triggered whenever a specified element locator is detected on the page. This function, known as a handler, is responsible for removing the overlay or taking any necessary actions to mitigate its impact on the test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Usage:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's face a common foe: the cookie consent dialog. We can use addLocatorHandler to automatically dismiss it whenever it appears:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLocatorHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Accept all cookies&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Reject all cookies&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Start here&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this scenario, when the &lt;em&gt;Accept all cookies&lt;/em&gt; button appears (our trigger), the handler function clicks the &lt;em&gt;Reject all cookies&lt;/em&gt; button instead. This dismisses the dialog and allows your test to proceed as planned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of addLocatorHandler:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Improved Test Reliability: By automatically handling overlays, tests become more robust and reliable, reducing the chances of false positives or test failures due to unexpected elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Simplified Test Maintenance: With addLocatorHandler, there's no need to manually handle overlays in each test case. The logic to dismiss overlays is centralized, making tests easier to maintain and update.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enhanced Test Efficiency: By seamlessly handling interruptions, tests can execute more efficiently without unnecessary delays caused by manual intervention or waiting for overlays to disappear.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Learn More:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For more details on using addLocatorHandler, refer to the official Playwright documentation: &lt;a href="https://playwright.dev/docs/next/api/class-page#page-add-locator-handler" rel="noopener noreferrer"&gt;Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, &lt;em&gt;addLocatorHandler&lt;/em&gt; simplifies handling overlays in Playwright tests, boosting test reliability and efficiency. It empowers testers to focus on core test logic without worrying about unexpected interruptions.&lt;/p&gt;

&lt;p&gt;Don’t forget to Follow me on &lt;a href="https://www.linkedin.com/in/bitwisebro" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; and &lt;a href="https://github.com/bitwisebro" rel="noopener noreferrer"&gt;Github&lt;/a&gt;!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://in.linkedin.com/in/bitwisebro?trk=profile-badge" rel="noopener noreferrer"&gt;Gaurav J.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>automation</category>
      <category>testing</category>
      <category>testdev</category>
    </item>
    <item>
      <title>Managing Multiple Git/GitHub Accounts with SSH</title>
      <dc:creator>Gaurav Jani</dc:creator>
      <pubDate>Wed, 12 Jul 2023 19:30:07 +0000</pubDate>
      <link>https://dev.to/bitwisebro/managing-multiple-github-git-accounts-with-ssh-4io9</link>
      <guid>https://dev.to/bitwisebro/managing-multiple-github-git-accounts-with-ssh-4io9</guid>
      <description>&lt;p&gt;Managing multiple GitHub Git accounts can be a challenge, especially when it comes to handling authentication and access. However, using SSH keys and configuring your SSH setup can streamline the process and make it more convenient. In this post, we'll explore the steps to handle multiple GitHub Git accounts using SSH.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Generate SSH keys for each GitHub account&lt;/strong&gt;&lt;br&gt;
To begin, generate SSH keys for each GitHub account you want to manage. Open your terminal or command prompt and run the following command, replacing "&lt;a href="mailto:your_email@example.com"&gt;your_email@example.com&lt;/a&gt;" with the email address associated with your GitHub account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -t ed25519 -C "your_email@example.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxmph9n7pri4g7dh4ua1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxmph9n7pri4g7dh4ua1.png" alt="Generate SSH key" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember to provide a unique name for each SSH key, such as "id_ed25519_account1" or "id_ed25519_account2". You can also set a passphrase for additional security. In above screenshot, I've entered 'gh-bitwisebro' as name for my SSH key file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Add SSH keys to the SSH Agent for Convenient Authentication&lt;/strong&gt;&lt;br&gt;
To avoid entering the SSH key passphrase every time you authenticate with your GitHub accounts, we can leverage the SSH Agent. The SSH Agent is a program that securely holds your SSH keys, allowing for seamless authentication during your Git operations.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open command prompt in the &lt;code&gt;.ssh&lt;/code&gt; folder add the SSH keys to agent using:
&lt;code&gt;ssh-add id_ed25519_account1&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember to replace &lt;code&gt;id_ed25519_account1&lt;/code&gt; with your filename! My filename is &lt;code&gt;gh-bitwisebro&lt;/code&gt; so I'll execute following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh-add gh-bitwisebro&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq3zscqd16aeymk52t2zq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq3zscqd16aeymk52t2zq.png" alt="Adding SSH key to SSH Agent" width="800" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: Some of you might face errors like &lt;code&gt;ssh-add error connecting to agent&lt;/code&gt; while adding SSH keys to SSH Agent. In that case follow following steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Makesure you've &lt;code&gt;openSSH Client&lt;/code&gt; and &lt;code&gt;openSSH Server&lt;/code&gt; installed. (You can do it from optional features menu in windows)&lt;/li&gt;
&lt;li&gt;Make sure your &lt;code&gt;openSSH Authentication Agent&lt;/code&gt; is running. (In windows, you can do it from Services)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Add SSH keys to your GitHub accounts&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;navigate to .ssh folder: &lt;code&gt;cd C:\Users\Gaurav Jani/.ssh/gh-bitwisebro&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Open this folder in VS Code: &lt;code&gt;code .&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Now copy the key from public file i.e. file that has &lt;code&gt;.pub&lt;/code&gt; extension&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz8nf4gu7drdn9i253v2r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz8nf4gu7drdn9i253v2r.png" alt="Copy the public key" width="800" height="181"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Log in to your GitHub account for the first account and navigate to "Settings". In the left sidebar, click on "SSH and GPG keys". Add a new SSH key by providing a descriptive title and pasting the contents of the corresponding .pub file generated in Step 1. Repeat this step for each GitHub account you want to associate with an SSH key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn9hwj2kp6jw6f03b61ss.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn9hwj2kp6jw6f03b61ss.png" alt="Go to SSH and GPG key section in github" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frlyfgzcg5etvwacg3q0i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frlyfgzcg5etvwacg3q0i.png" alt="Add SSH key to Github" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Create or modify your SSH configuration&lt;/strong&gt;&lt;br&gt;
Next, create or modify your SSH configuration file. Open it in your preferred text editor. We've already opened that folder in VS Code.&lt;/p&gt;

&lt;p&gt;Create a file called &lt;code&gt;config&lt;/code&gt; in the folder, i.e. &lt;code&gt;.ssh&lt;/code&gt; folder&lt;/p&gt;

&lt;p&gt;Add the following lines for each GitHub account, replacing the placeholders with your own values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Account 1
Host github-account1
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_account1

# Account 2
Host github-account2
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_account2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my Case, I'll add something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm53f6oatoaplnnu1nl7i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm53f6oatoaplnnu1nl7i.png" alt="Example config file" width="800" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Save and close the file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Test the SSH connections&lt;/strong&gt;&lt;br&gt;
To ensure that your SSH connections are properly configured, open your terminal and run the following command for each GitHub account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -T git@github-account1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -T git@github-account2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is set up correctly, you should see a message like: "Hi username! You've successfully authenticated...".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcn1kli3vds0b0bp48nax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcn1kli3vds0b0bp48nax.png" alt="Testing Github SSH connection" width="800" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Configure your Git repositories&lt;/strong&gt;&lt;br&gt;
Lastly, configure your Git repositories to use the appropriate SSH URLs. For existing repositories, update their remote URL using the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote set-url origin git@github-account1:username/repository.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For new repositories, when cloning, use the SSH URL with the configured hostname:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone git@github-account2:username/new-repository.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopgj70nedfio3hxz2vgz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopgj70nedfio3hxz2vgz.png" alt="Getting correct SSH URL for github repo" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I'll clone the above repo using:&lt;br&gt;
&lt;code&gt;git clone git@gh-bitwisebro:bitwisebro/Learn-Git.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Refer the image:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkkfnfd6xlljy29ernka7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkkfnfd6xlljy29ernka7.png" alt="Cloning git repo using SSH" width="800" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;:&lt;br&gt;
By following these steps, you can easily manage multiple GitHub Git accounts using SSH. This approach allows you to switch between accounts seamlessly and ensures secure authentication. With separate SSH keys and host aliases, you can streamline your Git workflows and maintain a clear separation between your different GitHub accounts.&lt;/p&gt;

&lt;p&gt;If you found this guide helpful and want to stay connected, I invite you to connect with me on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/bitwisebro/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/bitwisebro/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/bitwisebro" rel="noopener noreferrer"&gt;https://github.com/bitwisebro&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feel free to reach out, ask questions, or explore more of my work on these platforms. Let's connect and continue the conversation!&lt;/p&gt;

&lt;p&gt;Thank you for reading and happy coding!&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>cli</category>
      <category>linux</category>
    </item>
    <item>
      <title>How to Record Selenium Test Execution Video with TestNG &amp; Java?</title>
      <dc:creator>Gaurav Jani</dc:creator>
      <pubDate>Fri, 16 Jun 2023 06:31:10 +0000</pubDate>
      <link>https://dev.to/bitwisebro/how-to-record-selenium-test-execution-video-with-testng-java-4mpm</link>
      <guid>https://dev.to/bitwisebro/how-to-record-selenium-test-execution-video-with-testng-java-4mpm</guid>
      <description>&lt;p&gt;If you are working on a Selenium test automation project, it is essential to have a record of your test execution to review and analyze the results. Recording a video of your Selenium test execution can help you identify any issues or errors that occur during the test run. In this article, we will discuss how to record Selenium test execution video with Java.&lt;/p&gt;

&lt;p&gt;I personally prefer &lt;strong&gt;monte screen recorder&lt;/strong&gt; library! It works pretty well and thats what we are gonna learn today! Let’s start!&lt;/p&gt;

&lt;p&gt;Step 1: &lt;strong&gt;Add monte-screen-recorder dependency in your project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are using maven, You can add following dependency to your project’s pom.xml file. This will download the required packages for screen recording and you can use them in your Selenium test automation project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;org.monte.media&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;monte-screen-recorder&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;0.7.7.1&amp;lt;/version&amp;gt;
    &amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2: &lt;strong&gt;Import Required Packages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To start with, we need to import the required packages for screen recording. Here are the packages that we need in the Java Class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; import org.monte.media.math.Rational;
    import org.monte.screenrecorder.ScreenRecorder;
    import org.monte.media.Format;
    import org.monte.media.FormatKeys.MediaType;
    import org.monte.media.VideoFormatKeys;
    import org.monte.media.math.Rational;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: &lt;strong&gt;Create a Method to Start the Screen Recording&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this step, we will create a method that will start the screen recording. Here is the code for this method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; public static ScreenRecorder startRecording(String fileName) throws Exception {
    GraphicsConfiguration gc = GraphicsEnvironment
    .getLocalGraphicsEnvironment()
    .getDefaultScreenDevice()
    .getDefaultConfiguration();

    ScreenRecorder screenRecorder = new ScreenRecorder(gc,
    new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI),
    new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
    CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, (int) 24, FrameRateKey,
    Rational.valueOf(15), QualityKey, 1.0f, KeyFrameIntervalKey, (int) (15 * 60)),
    new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, “black”, FrameRateKey, Rational.valueOf(30)),
    null, new File(fileName));

    screenRecorder.start();

    return screenRecorder;
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this method, we are creating a new instance of the ScreenRecorder class and setting up the required configurations for screen recording.&lt;/p&gt;

&lt;p&gt;Step 4: &lt;strong&gt;Create a Method to Stop the Screen Recording&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this step, we will create a method that will stop the screen recording. Here is the code for this method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void stopRecording(ScreenRecorder screenRecorder) throws Exception {
    screenRecorder.stop();
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this method, we are simply calling the stop() method of the ScreenRecorder class to stop the screen recording.&lt;br&gt;
Step 5: Start and Stop Screen Recording in Selenium Test&lt;/p&gt;

&lt;p&gt;In this step, we will start and stop the screen recording in our Selenium test. Here is the code for this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @Test
    public void testRecording() throws Exception {
    // Start screen recording
    ScreenRecorder screenRecorder = startRecording(“testRecording.avi”);

    // Your Selenium test code goes here

    // Stop screen recording
    stopRecording(screenRecorder);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, we are starting the screen recording before our Selenium test code and stopping it after the test execution is completed.&lt;/p&gt;

&lt;p&gt;Conclusion: In this article, we have discussed how to record Selenium test execution video with Java. By following the above steps, you can easily record a video of your Selenium test execution and analyze the results. This can help you identify any issues or errors that occur during the test run and improve the overall quality of your test automation project.&lt;/p&gt;

&lt;p&gt;Don’t forget to Follow me on &lt;a href="https://www.linkedin.com/in/bitwisebro" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; and &lt;a href="https://github.com/bitwisebro" rel="noopener noreferrer"&gt;Github&lt;/a&gt;!!&lt;/p&gt;

</description>
      <category>java</category>
      <category>selenium</category>
      <category>testing</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
