public void CreateNewTimenMatirials(TimeMaterialData timematerialdata) { //Choose Time from the list if (timematerialdata.TypeCode == "T") { materialTypeCode.Click(); WaitForDisplay(By.XPath(".//*[@id='TypeCode_listbox']/li[2]"), 2); timeTypeCode.Click(); } txtCode.SendKeys(timematerialdata.Code); txtDescrip.SendKeys(timematerialdata.Description); //WaitForDisplay(By.XPath(".//*[@id='TimeMaterialEditForm']/div/div[4]/div/span[1]/span/input[1]"), 3); Thread.Sleep(3000); txtPricePerUnit.SendKeys(timematerialdata.PricePerUnit); Thread.Sleep(3000); //Upload file string file = @timematerialdata.UploadFile; uploadFile.SendKeys(file); btnSave.Click(); }
//Read the csv file public static IEnumerable <TimeMaterialData> ReadDataFromCsv() { using (var reader = new StreamReader(File.OpenRead(@"C:\Users\gaofei88\Documents\Visual Studio 2015\Projects\CrossBrowserTesting\SauceLab\TestData\TimeMaterialData.csv"))) { while (!reader.EndOfStream) { TimeMaterialData data = new TimeMaterialData(); var line = reader.ReadLine(); var values = line.Split(','); data.TypeCode = values[0]; data.Code = values[1]; data.Description = values[2]; data.PricePerUnit = values[3]; data.UploadFile = values[4]; yield return(data); } } }
public void TestCreateSucess(TimeMaterialData timematerialdata) { driver.Navigate().GoToUrl("http://horse-dev.azurewebsites.net/Account/Login?ReturnUrl=%2f"); LoginPage loginpage = new LoginPage(driver); loginpage.LoginWithValidData(); HomePage homepage = new HomePage(driver); homepage.NavigateToTimenMaterialsPage(); TimenMaterialPage timematerialpage = new TimenMaterialPage(driver); timematerialpage.ClickCreateNew(); TimeMaterialCreatePage timematerialcreatepage = new TimeMaterialCreatePage(driver); timematerialcreatepage.CreateNewTimenMatirials(timematerialdata); Assert.IsTrue(timematerialpage.FindCertainRow(timematerialdata.Code)); }