DevLabs Alliance - WhatsApp
DevLabs Alliance Logo

Open Visual Studio

Click on File >> New >> Project



In New Project template,


  • Click on Visual C# in the left panel.
  • Click on Console Application.
  • Enter Name as
  • Click on OK.



After the successful creation of the project, the below screen would be displayed:

Setting up Selenium WebDriver in Visual Studio

To install the Selenium WebDriver, follow the below steps:

Click on Tools >> NuGet Package Manager >> Manage NuGet Package for Solution



In the next screen,


  • Click on Browse.
  • Search for Selenium in the Search bar.
  • Select the first result, “Selenium.WebDriver”
  • Check the project checkbox.
  • Click on Install.



Review the changes and click on OK in the Preview pop-up.

After the successful installation of Selenium WebDriver, the below message will be displayed in the Output window.



Downloading Chrome Driver

We would be executing our Selenium scripts as well as automating any web application in Chrome browser. Hence, to launch the Chrome browser, we need to have Chrome Driver downloaded in the system.


To download Chrome Driver, follow the below steps:


  • Check the version of your Chrome browser.
  • Open Chrome browser
  • Click on three vertical dots on top most right-hand side in the browser.


Click on Help >> About Google Chrome.



In the next screen, Chrome version is displayed in About Chrome section



Open below link to download Chrome Driver:

https://chromedriver.chromium.org/downloads

Based on the Chrome browser version, click on the Chrome Driver download link:



On click of the download link, a window will open specifying the chrome Driver for various platforms. Download the one according to your system’s configuration.



On click of the link, Chrome Driver zip file will get downloaded. Unzip the file and place it in some folder.



Writing and executing first Selenium test

Right click on Project and click on Add >> New Item...



In Add New Item template, click on Class under Visual C# items and provide the Name as DLADemo.cs and click on Add button.



In Add New Item template, click on Class under Visual C# items and provide the Name as DLADemo.cs and click on Add button.



New class DLADemo.cs will get added to the project.


Write the following code in DLADemo.cs file:

Open the Program.cs and write the following code in Main method.

Click on Start to run the application.

The browser will open and run the scripts written, and the browser will get closed.

Creating NUnit test class in Selenium

To install the NUnit Framework, follow the below steps:


Click on Tools >> NuGet Package Manager >> Manage NuGet Package for Solution…

In the next screen,


  • Click on Browse.
  • Search for NUnit in the Search bar.
  • Select the first result, “NUnit”.
  • Check the project checkbox.
  • Click on Install.

Review the changes and click on OK in the Preview pop-up.

Installing NUnit Test Adapter

Click on Tools >> NuGet Package Manager >> Manage NuGet Package for Solution…


In the next screen,

  • Click on Browse.
  • Search for NUnitTestAdapter in the Search bar.
  • Select the first result, “NUnit3TestAdapter”.
  • Check the project checkbox.
  • Click on Install.


Review the changes and click on OK in the Preview pop-up.


After successful installation of NUnit Test Adapter, the below message will be displayed in the Output window.

Writing and executing first Selenium test with NUnit annotations

Write the below code in DLADemo.cs file.


Click on Build >> Build Solution.


Once the build is successful, click on Test >> Windows >> Test Explorer.


Test Explorer window will be opened and the test script with annotation Test(“OpenUrl”) will be displayed in the Test Explorer window.


Select the test and right click on it. Click on Run Selected Tests.


Selenium will open the browser, then execute the test script and will close the browser and test case will get passed and will be displayed under Passed Tests in Test Explorer window.

Know Our Author

DevLabs Alliance Author Bio

Admin


DevLabs Alliance TwitterDevLabs Alliance LinkedInDevLabs Alliance Instagram

Author Bio

DevLabs Alliance conducts career transformation workshops & training in Artificial Intelligence, Machine Learning, Deep Learning, Agile, DevOps, Big Data, Blockchain, Software Test Automation, Robotics Process Automation, and other cutting-edge technologies.

INQUIRY

Want To Know More


Email is valid



Phone


By tapping continuing, you agree to our Privacy Policy and Terms & Conditions

“ The hands-on projects helped our team put theory into practice. Thanks to this training, we've achieved seamless collaboration, faster releases, and a more resilient infrastructure. ”
DevLabs Alliance Blogs Page Review
Vijay Saxena

SkillAhead Solutions

DevLabs Alliance Footer section
DevLabs Alliance LinkedIn ProfileDevLabs Alliance Twitter ProfileDevLabs Alliance Facebook ProfileDevLabs Alliance Facebook Profile
DevLabs Alliance Logo

USA

1603, Capitol Avenue, Suite 413A, 2659, Cheyenne, WY 82001, USA

DevLabs Alliance ISO 9001

DevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer Section

`Copyright © DevLabs Alliance. All rights Reserved`

|

Refund & Reschedule Policy

Privacy Policy

Terms of Use