Рет қаралды 4,478
Selenium Data Driven Testing using XML file in MS Test
#Selenium #WebDriver #Automation #datadriventesting
0:47 What is a XML file
1:12 XML file sample
1:50 Code demo - XML file creation
3:45 Code demo - Creation of test method
5:00 Test method execution
5:52 Possible interview questions on data driven testing using csv file
Data driven testing using csv file
What is an XML file?
1. XML stands for eXtensible Markup Language
2. XML is a markup language much like HTML
3. XML is used to store and transport data
4. XML is self-descriptive
5. Easy to read
Possible Interview Questions
1. How to achieve the data driven testing using XML file
Code :
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML","|DataDirectory|\\data.xml", "user", DataAccessMethod.Sequential)]
[TestMethod]
public void DataDrivenTestingUsingXMLFile()
{
IWebDriver driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = "uitestpractice....";
driver.FindElement(By.Id("FirstName")).SendKeys(TestContext.DataRow[0].ToString());
driver.FindElement(By.Id("LastName")).SendKeys(TestContext.DataRow[1].ToString());
driver.FindElement(By.Id("EnrollmentDate")).SendKeys(TestContext.DataRow[2].ToString());
driver.FindElement(By.XPath("//input[@type='submit']")).Click();
Thread.Sleep(2000);
driver.Quit();
}