Kịch bản thử nghiệm:
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using VTACourses.PageObjects;
namespace VTACourses
{
class SeleniumDemo
{
IWebDriver driver;
[SetUp]
public void startBrowser()
{
driver = new ChromeDriver("D:\\TESTER\\Automation Testing\\Project"); //Thư mục cuối cùng chứa File Chromedriver.exe
driver.Manage().Window.Maximize(); //Để bung fullscreen màn hình cái Chrome
}
[Test]
public void DemoGetElement()
{
driver.Url = "https://demoqa.com/";
Thread.Sleep(3000);
IWebElement moduleElement = driver.FindElement(By.XPath("//*[name()='path' and contains(@d,'M16 132h41')]"));
moduleElement.Click();
Thread.Sleep(2000);
IWebElement menuTextBox = driver.FindElement(By.XPath("//span[contains(text(),'Text Box')]"));
menuTextBox.Click();
Thread.Sleep(2000);
}
[TearDown]
public void closeBrowser()
{
driver.Close();
}
}
}
Kịch bản thử nghiệm:
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using VTACourses.PageObjects;
namespace VTACourses
{
class SeleniumDemo
{
IWebDriver driver;
[SetUp]
public void startBrowser()
{
driver = new ChromeDriver("D:\\TESTER\\Automation Testing\\Project"); //Thư mục cuối cùng chứa File Chromedriver.exe
driver.Manage().Window.Maximize(); //Để bung fullscreen màn hình cái Chrome
}
[Test]
public void DemoGetElement()
{
driver.Url = "https://demoqa.com/";
Thread.Sleep(5000);
IWebElement moduleElement = driver.FindElement(By.XPath("//*[name()='path' and contains(@d,'M16 132h41')]"));
moduleElement.Click();
Thread.Sleep(2000);
IWebElement menuTextBox = driver.FindElement(By.XPath("//span[contains(text(),'Text Box')]"));
menuTextBox.Click();
Thread.Sleep(2000);
//SendKeys (Nhập liệu)
IWebElement txtFullName = driver.FindElement(By.Id("userName"));
IWebElement txtEmail = driver.FindElement(By.Id("userEmail"));
IWebElement txtCurentAddress = driver.FindElement(By.Id("currentAddress"));
IWebElement txtPermanentAddress = driver.FindElement(By.Id("permanentAddress"));
//Click (Button)
IWebElement btnSubmit = driver.FindElement(By.Id("submit"));
txtFullName.SendKeys("VTA Courses");
Thread.Sleep(1000);
txtEmail.SendKeys("abc@email.com");
Thread.Sleep(1000);
txtCurentAddress.SendKeys("Đồng Tháp");
Thread.Sleep(1000);
txtPermanentAddress.SendKeys("Cần Thơ");
Thread.Sleep(1000);
btnSubmit.Click();
Thread.Sleep(3000);
}
[TearDown]
public void closeBrowser()
{
driver.Close();
}
}
}
Anh Tester
Đường dẫu khó chân vẫn cần bước đi
Đời dẫu khổ tâm vẫn cần nghĩ thấu