public void TestDataDrivenCSV() { // Iterate each row in the CSV file, use data for test scripts String csvFilePath = TestHelper.ScriptDir() + @"\testdata\users.csv"; IEnumerable <IList <string> > data = CSVReader.FromFile(csvFilePath); foreach (IList <string> nextLine in data) { // nextLine[] is an array of values from the line String login = nextLine[1]; String password = nextLine[2]; String expected_text = nextLine[3]; if (login.Equals("LOGIN")) { // head row continue; } driver.Navigate().GoToUrl("http://travel.agileway.net"); driver.FindElement(By.Name("username")).SendKeys(login); driver.FindElement(By.Name("password")).SendKeys(password); driver.FindElement(By.Name("username")).Submit(); Assert.IsTrue(driver.FindElement(By.TagName("body")).Text.Contains(expected_text)); try { // if logged in OK, try log out, so next one can continue driver.FindElement(By.LinkText("Sign off")).Click(); } catch (Exception ex) { // ignore } } }
public void TestReadExtnernalFile() { String filePath = TestHelper.ScriptDir() + @"\testdata\in.xml"; Console.WriteLine(filePath); Assert.IsTrue(File.Exists(filePath)); String content = File.ReadAllText(filePath); Console.WriteLine("content = " + content); }
public void TestByPassBasicAuthenticationWithAutoAuthPlugin() { /* you need have 'testing' profile set up in Firefox, see the book for instructions */ // change to your testing foler FirefoxProfile firefoxProfile = new FirefoxProfile(GetFirefoxProfileFolderByName("testing")); firefoxProfile.AddExtension(TestHelper.ScriptDir() + @"\autoauth-2.1-fx+fn.xpi"); driver = new FirefoxDriver(firefoxProfile); driver.Navigate().GoToUrl("http://itest2.com/svn-demo/"); // got in, click a link driver.FindElement(By.LinkText("tony/")).Click(); System.Threading.Thread.Sleep(1000); driver.Quit(); }
public void TestFileUpload() { String filePath = TestHelper.ScriptDir() + @"\testdata\users.csv"; driver.FindElement(By.Name("document[file]")).SendKeys(filePath); }