dir.by  
Поиск >>

Компьютер, программы
→
Юнит тестирование (MSTest, NUnit, xUnit, Moq) и Автоматическое тестирование (компьютер сам водит мышкой)
→
Automated Testing
 Write an automated test on C# using Selenium for Web site 
посмотрели 4823 раз
обновлено: 29 February 2024
Download the example
ConsoleApp1AutWebTest.zip ...
Size: 74 kilobytes
Step 1. Open Visual Studio
If you do not have Visual Studio installed you need install Visual Studio...
Open Visual Studio 2022
or
Open Visual Studio 2019
Step 2. Creating a new console
Step 3. Add NuGet package with Selenium
Step 4. Let's add the code
  C#     File Program.cs
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace ConsoleApp1
{
     internal class Program
     {
          static void Main(string[] args)
          {
               IWebDriver driver = new ChromeDriver();
              
               driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/web-form.html");
              
               var button1 = driver.FindElement(By.ClassName("btn-outline-primary"));

               Thread.Sleep(4000);
               button1.Click();

               Thread.Sleep(14000);
          }
     }
}
Result
Run this project in Visual Studio and once launched, you will see:
1) Google Chrome will open on its own
2) The web page will load
3) After 4 seconds, the button will be pressed
4) After 14 seconds, the application will close
 
← Previous topic
What is automated testing?
 
Next topic →
Download and install the Microsoft application WinAppDriver
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

Новость "Черная пятница" Dreame в Беларуси – две недели скидок до 3400 рублей
 
• What is Unit Testing?
MSTest (UnitTest) testing
• What is MSTest (UnitTest)? (Unit Testing Framework from Microsoft)
• Sites to learn MSTest (UnitTest) testing
NUnit Testing
• What is NUnit ? (unit testing framework)
• Writing a Console C# Application with NUnit Testing
xUnit testing
• What is xUnit? (unit testing framework)
• Sites to learn xUnit testing
Moq (mock) testing
• What is Mock (moq) testing?
• Writing a C# Application with Mock (moq) Testing
• Websites to learn Moq testing
• What is automated testing?
Automated Testing
• Write an automated test on C# using Selenium for Web site
• Download and install the Microsoft application WinAppDriver
• Launch the Microsoft WinAppDriver application
• Writing an automatic C# test for a standard calculator from Windows
• Writing an automated test for a WPF C# application (using Nuget.Appium and the AutomationProperties.AutomationId property)

  Ваши вопросы присылайте по почте: info@dir.by