/*public void test() * { * string script = System.IO.File.ReadAllText(@"C:\Users\long\Documents\test9.js"); * script += "simulateHTML5DragAndDrop(arguments[0], arguments[1])"; * IJavaScriptExecutor executor = (IJavaScriptExecutor)PropertiesCollection.driver; * executor.ExecuteScript(script, toscabot, box); * }*/ public void test() { int order = 1; while (order < 7) { for (int i = 2; i < 8; i++) { IWebElement start = PropertiesCollection.driver.FindElement(By.XPath("/html/body/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[1]/div/table/tbody/tr[" + i + "]")); IWebElement finish = PropertiesCollection.driver.FindElement(By.XPath("/html/body/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div/table/tbody/tr[1]")); string id = GetMethods.GetTextTask(start); if (order == Convert.ToInt32(id)) { /*string script = System.IO.File.ReadAllText(@"C:\Users\long\Documents\test9.js"); * script += "simulateHTML5DragAndDrop(arguments[0], arguments[1])"; * IJavaScriptExecutor executor = (IJavaScriptExecutor)PropertiesCollection.driver; * executor.ExecuteScript(script, start, finish);*/ Actions action = new Actions(PropertiesCollection.driver); action.DragAndDrop(start, finish).Build().Perform(); order++; break; } } } Thread.Sleep(800); Assert.IsTrue(Completed.Text.Contains("Good job"), "Not Completed"); ClosePopUp.Click(); }
public void test() { generateTXT.Click(); string text = GetMethods.GetTextValue(generateTXT); Console.WriteLine(text); Regex regex = new Regex(@"\d+"); Match match = regex.Match(text); if (match.Success) { SetMethods.EnterText(firstNum, match.Value); } match = match.NextMatch(); if (match.Success) { SetMethods.EnterText(secNum, match.Value); } match = match.NextMatch(); if (match.Success) { SetMethods.EnterText(thirdNum, match.Value); } firstNum.Click(); Thread.Sleep(800); Assert.IsTrue(Completed.Text.Contains("Good job"), "Not Completed"); ClosePopUp.Click(); }
public void test() { booksBtn.Click(); string text = GetMethods.GetTextValue(XMLText); Console.WriteLine(text); // Copy and save into an XML file using (StreamWriter sw = File.CreateText(@"C:\Users\long\Documents\xmldoc.xml")) { sw.WriteLine(text); } // Read from the saved XML file XmlTextReader reader = new XmlTextReader(@"C:\Users\long\Documents\xmldoc.xml"); string ISBN = ""; while (reader.Read()) { if (reader.NodeType.ToString().Equals("Element")) { if (reader.Name.Equals("title")) { reader.Read(); if (reader.NodeType.ToString().Equals("Text")) { if (reader.Value.ToString().Equals("Testing Computer Software")) { // Read until ISBN row is reached for (int i = 0; i < 12; i++) { reader.Read(); } ISBN = reader.Value.ToString(); break; } } } } } SetMethods.EnterText(result, ISBN); Thread.Sleep(800); Assert.IsTrue(Completed.Text.Contains("Good job"), "Not Completed"); ClosePopUp.Click(); }
public void test() { generate.Click(); Regex year1 = new Regex(@"\d{4}"); Regex monthDay = new Regex(@"\d{1,2}"); string date1 = GetMethods.GetTextValue(dateGenerated); string date2, finalDate = ""; Match match = monthDay.Match(date1); if (match.Success) { if (Convert.ToInt32(match.Value) == 11) { date2 = "-01-01"; match = year1.Match(date1); finalDate = (Convert.ToInt32(match.Value) + 1) + date2; } if (Convert.ToInt32(match.Value) == 12) { date2 = "-02-01"; match = year1.Match(date1); finalDate = (Convert.ToInt32(match.Value) + 1) + date2; } else { if ((Convert.ToInt32(match.Value) + 2 + "").Length == 1) { date2 = "-0" + (Convert.ToInt32(match.Value) + 2) + "-01"; } else { date2 = "-" + (Convert.ToInt32(match.Value) + 2) + "-01"; } match = year1.Match(date1); finalDate = Convert.ToInt32(match.Value) + date2; } } SetMethods.EnterText(dateSolution, finalDate); done.Click(); Thread.Sleep(800); Assert.IsTrue(Completed.Text.Contains("Good job"), "Not Completed"); ClosePopUp.Click(); }
public void test() { ClickMe.Click(); string text = GetMethods.GetTextValue(GenerateText); SelectElement selectList = new SelectElement(ddl); IList <IWebElement> options = selectList.Options; for (int j = 2; j < options.Count; j++) { string optionText = options[j].Text.ToString(); Console.WriteLine("{0} : {1}", text, optionText); if (text.Equals(optionText)) { SetMethods.SelectDropDown(ddl, optionText); break; } } Submit.Click(); Thread.Sleep(800); Assert.IsTrue(Completed.Text.Contains("Good job"), "Not Completed"); ClosePopUp.Click(); }