There are more connected devices than ever before as IoT (Internet of Things) technology is gaining traction. IoT testing is conducted to test IoT technology based devices. The various types of testing for IoT systems are as follows:
Usability Testing – To test the usability of an IoT system
Compatibility Testing – To check the compatibility of devices in IoT system
Step 3) The below screen will be displayed once the project is successfully created.
Set up Visual Studio with Selenium WebDriver:
Step 1) Navigate to Project-> Manage NuGet Packages
Step 2) In the next screen
Search for Selenium on the resultant screen
Select the first search result
Click on ‘Install’
Step 3) The below message will be displayed once the package is successfully installed
Steps to install NUnit Framework:
Step 1) Navigate to Project-> Manage NuGet Packages
Step 2) In the next window
Search for NUnit
Select the search result
Click Install
Step 3) The below message will appear once the installation is complete.
Steps to download NUnit Test Adapter
Please note that the below steps work only for 32-bit machines. For 64-bit machines, you need to download the ‘NUnit3 Test Adapter’ by following the same process as mentioned below.
Step 1) Navigate to Project-> Manage NuGet Packages
Step 2) In the next window
Search NUnitTestAdapter
Click Search Result
Click Install
Step 3) Once install is done you will see the following message
Steps to download Chrome Driver
Step 1) Navigate to Project-> Manage NuGet Packages
Step 2) In the next window
Search for Chromdriver
Select the search result
Click Install
Step 3) System may asked for permission. Click on ‘Yes to All’
Step 4) The below message will appear once the installation is complete.
Selenium and NUnit framework:
Selenium with NUnit framework allows differentiating between various test classes. NUnit also allows using annotations such as SetUp, Test, and TearDown to perform actions before and after running the test.
NUnit framework can be integrated with Selenium by creating a NUnit
test class and running the test class using NUnit framework.
The below are the steps needed to create and run a test class using NUnit framework.
Steps to create a NUnit Test class in Selenium:
Step 1) In the Solution Explorer, Right clicked on project > Add > Class
Step 2) Class creation window will appear
Provide a name to the class
Click on Add button
Step 3) The below screen will appear.
Step 4) Add the following code to the created class. Please note that you need to specify the location of ‘chromdriver.exe’ file during chrome driver initialization.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Chrome;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit;
namespace RnD
{
[TestFixture]
public class TestDemo1
{
public IWebDriver driver;
[SetUp]
public void Initialize()
{
driver = new ChromeDriver();
}
[Test]
public void BrowserTest()
{
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("https://www.google.com/");
}
[TearDown]
public void closeBrowser()
{
driver.Close();
}
}
}
Step 4) Click on ‘Build’ -> ‘Build Solution’ or keypress ‘Ctrl + Shift + B’
Step 5) Once the build is successful, we need to open the Test Explorer window. Click on Test -> Windows -> Test Explorer
Step 6) Test Explorer window opens with the list of available tests. Right-click on Test Explorer and select Run Selected Tests
Step 7) Selenium must open the browser with specified URL and close the browser. Test case status will be changed to ‘Pass’ on the Test Explorer window.