/// <summary> /// Wait for the URL to be matching with the given text for given timeout /// </summary> /// <param name="urlText"></param> /// <param name="timeOutSeconds"></param> public static void WaitForUrlMatches(string urlText, TimeSpan timeOutSecs) { try { WebDriverWait wait = new WebDriverWait(DriverInstance.Instance, timeOutSecs); wait.Until(ExpectedConditions.UrlMatches(urlText)); LoggerInstance.log.Info("Driver explicitly waits " + timeOutSecs + " seconds for url text matches with " + "\"" + urlText + "\"."); } catch (NoSuchElementException elementNotPresent) { LoggerInstance.log.Error(elementNotPresent.Message, elementNotPresent); } catch (WebDriverTimeoutException webdriverTimeOut) { LoggerInstance.log.Error(webdriverTimeOut.Message, webdriverTimeOut); } catch (TimeoutException timeOutEx) { LoggerInstance.log.Error(timeOutEx.Message, timeOutEx); } catch (Exception e) { LoggerInstance.log.Error(e.Message, e); } }
/// <summary> /// Clicks the user-specified button or link and then waits for a window to close or open, or a page to load, /// depending on the button that was clicked /// </summary> /// <param name="buttonOrLinkElem">The element to click on</param> public dynamic ClickToAdvance(IWebElement buttonOrLinkElem) { if (Browser.Exists(Bys.NotificationCreatorPage.SaveExitBtn)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == SaveExitBtn.GetAttribute("outerHTML")) { SaveExitBtn.Click(); // Browser.WaitForElement(Bys.EducationCenterPage.MyCoursesTtl, TimeSpan.FromSeconds(60), ElementCriteria.IsVisible, ElementCriteria.IsEnabled); Browser.WaitForElement(Bys.DashboardNotificationsPage.CreateNotificationBtn, TimeSpan.FromSeconds(90), ElementCriteria.IsEnabled); new WebDriverWait(Browser, TimeSpan.FromSeconds(90)).Until(ExpectedConditions.UrlContains("gme-competency/admin/dashboardcontent")); DashboardNotificationsPage DNP = new DashboardNotificationsPage(Browser); DNP.WaitForInitialize(); return(DNP); } } if (Browser.Exists(Bys.AMAPage.SignOutLnk)) { if (buttonOrLinkElem.GetAttribute("outerHTML") == SignOutLnk.GetAttribute("outerHTML")) { Browser.WaitForElement(Bys.AMAPage.LoadIcon, ElementCriteria.IsNotVisible); SignOutLnk.SendKeys(Keys.Tab); SignOutLnk.Click(); new WebDriverWait(Browser, TimeSpan.FromSeconds(115)).Until(ExpectedConditions.UrlMatches("https://logintest.ama-assn.org/account/logout")); return(this.Browser); } } else { throw new Exception("No button or link was found with your passed parameter. You either need to add this button to a new If statement, or if the button is already added, then the page you were on did not contain the button."); } return(null); }
public void Method() { wait.Until(ExpectedConditions.TitleIs("webdriver - Поиск в Google")); wait.Until(ExpectedConditions.TitleContains("webdriver - Поиск в")); wait.Until(ExpectedConditions.UrlContains("login.php")); wait.Until(ExpectedConditions.UrlToBe("http://pagination.js.org/")); var regex = @"\d"; wait.Until(ExpectedConditions.UrlMatches(regex)); wait.Until(ExpectedConditions.AlertIsPresent()); //В С# я не нашел wait.Until(ExpectedConditions.NumberOfWindowsToBe()); //нужно проверять то, что у элемента есть какой-то класс, вместо того, чтобы проверять стиль элемента. //как правило, разработчики не меняют стили напрямую, они присваивают классы. wait.Until(x => x.FindElement(By.CssSelector("locator")).GetAttribute("class").Contains("error")); wait.Until(ExpectedConditions.TextToBePresentInElement(element, "text")); wait.Until(ExpectedConditions.ElementToBeSelected(element, false)); wait.Until(ExpectedConditions.ElementToBeClickable(element)); //ElementToBeClickable - не соответствует своему названию. Сдесь проверяется то, что //елемент 1.Видимый, 2.Не disabled. И конечно, здесь нет никаких проверок, что эта кнопка НЕ ЗАКРЫТА никаким другим //элементом а если она прозрачная, то она будет считаться невидимой. Так, что название этого метода просто напросто врет. //По-настоящему ИНТЕРАКТИВНОСТЬ ОНО НЕ ПРОВЕРЯЕТ. //условие количества элементов с локатором var elements = driver.FindElements(By.CssSelector("locator")); wait.Until(x => elements.Count == 10); //но здесь мы возвращаем коллекцию элементов. var returnedElements = wait.Until(x => { var elements2 = x.FindElements(By.CssSelector("locaotr")); return(elements2.Count == 10 ? elements2 : null); }); //хз что это... var wait2 = new DefaultWait <IWebElement>(element); }
public dynamic UseDropDownOnRightSide(IWebElement LinkToClick) { HeaderMenuDropDown.Click(); Thread.Sleep(200); if (LinkToClick.GetAttribute("outerHTML") == SignOutLnk.GetAttribute("outerHTML")) { SignOutLnk.Click(); new WebDriverWait(Browser, TimeSpan.FromSeconds(45)).Until(ExpectedConditions.UrlMatches("https://logintest.ama-assn.org/account/logout")); return(this.Browser); } if (LinkToClick.GetAttribute("outerHTML") == HelpfromYourInstitutionLnk.GetAttribute("outerHTML")) { HelpfromYourInstitutionLnk.Click(); Browser.SwitchTo().Window(Browser.WindowHandles.Last()); Thread.Sleep(0500); Browser.Manage().Window.Maximize(); Thread.Sleep(0500); Browser.SwitchTo().Window(Browser.WindowHandles.First()).Close(); if (Browser.WindowHandles.Count > 1) { Browser.SwitchTo().Window(Browser.WindowHandles.First()).Close(); } Thread.Sleep(0500); Browser.SwitchTo().Window(Browser.WindowHandles.Last()); Browser.Manage().Window.Maximize(); Thread.Sleep(0500); HelpPage HP = new HelpPage(Browser); HP.WaitForInitialize(); return(HP); } return(null); }
public void WholeProgram_NewParsingCorrectly_Test_0() { using (var driver = new ChromeDriver()) { /* Initialization */ var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://tms.lionbridge.com/"); wait.Until(ExpectedConditions.UrlMatches("https://tms.lionbridge.com/")); string projectName = "Porsche Bal 2.0"; // Project Name TMSProjectsPage tmsProjectsPage = new TMSProjectsPage(driver); tmsProjectsPage.ClickChosenProject(projectName); TMSProjectHomePage tmsProjectHomePage = new TMSProjectHomePage(driver); tmsProjectHomePage.ChangeItemsPerPageToMinimum(driver); tmsProjectHomePage.StatusClick(); TMSStatusPage tmsStatusPage = new TMSStatusPage(driver); tmsStatusPage.AssingeeClick(); TMSAssigneesSubpage tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); tmsAssigneesSubpage.InitializeFiltersPanel(driver); if (tmsAssigneesSubpage.AssigneeCount == 1) { throw new Exception("Activities drop down list is empty. Program now will shut down. "); } tmsAssigneesSubpage.ChoseActivityOption(driver, "InternalReview"); tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); PageNavBar pageNavBar = new PageNavBar(driver); if (pageNavBar.PageList.IsPageListEmpty) { throw new Exception("Page list is empty. Program now will shut down. "); } pageNavBar.ItemsPerPage.ChoseDropDownOption(driver, "1000"); tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); /*AssigneesPage porscheAssigneesPage = new AssigneesPage(driver); * * porscheAssigneesPage.ChosenActivityClick(driver, "InternalReview"); * porscheAssigneesPage = new AssigneesPage(driver); * * PageBar testPageBar = new PageBar(driver); * testPageBar.ItemsPerPageSetMaximalValue(driver); * * AssigneesAndJobs asob = new AssigneesAndJobs(driver); * * List<StatusAssgineeInfo> listOfStatusAssgineeInfo = new List<StatusAssgineeInfo>(); * StatusAssgineeInfo auxiliary;*/ } }
public void NavigateToProducts_CreateOrder_CheckIfCreatedProductExists() { try { driver.Navigate().GoToUrl(localHostUrl); driver.FindElement(By.LinkText("Orders")).Click(); string orderUrl = driver.Url.ToLower(); driver.FindElement(By.Id("CreateNewOrder")).Click(); var customers = driver.FindElement(By.Id("CustomerId")); var selectElement = new SelectElement(customers); selectElement.SelectByValue("1"); var products = driver.FindElement(By.Id("ProductId")); selectElement = new SelectElement(products); selectElement.SelectByValue("1"); IWebElement element = driver.FindElement(By.Id("Quantity")); element.SendKeys("5"); driver.FindElement(By.Id("Submit")).Click(); WebDriverWait waiting = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); waiting.Until(ExpectedConditions.UrlMatches(orderUrl)); Assert.AreEqual(orderUrl, driver.Url.ToLower()); } catch (Exception e) { Debug.Print("Error: " + e); Assert.Fail(); } }
public void NavigateToCustomers_CreateCustomer_WaitForRedirectAfterSuccess() { try { driver.Navigate().GoToUrl(localHostUrl); driver.FindElement(By.LinkText("Customers")).Click(); string customersUrl = driver.Url.ToLower(); driver.FindElement(By.Id("CreateNewCustomer")).Click(); IWebElement element = driver.FindElement(By.Id("FirstName")); element.SendKeys("Teuvo"); element = driver.FindElement(By.Id("LastName")); element.SendKeys("Kirjanen"); element = driver.FindElement(By.Id("City")); element.SendKeys("Joensuu"); element = driver.FindElement(By.Id("Address")); element.SendKeys("Tulliportinkatu 11"); driver.FindElement(By.Id("Submit")).Click(); WebDriverWait waiting = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); waiting.Until(ExpectedConditions.UrlMatches(customersUrl)); Assert.AreEqual(customersUrl, driver.Url.ToLower()); } catch (Exception e) { Debug.Print("Error: " + e); Assert.Fail(); } }
public void Login_submit_success() { driver.Navigate().GoToUrl(Configuration.SITE_URL); var page = new HomePage(this.driver); page.EmailTextField.SendKeys("*****@*****.**"); page.PasswordTextField.SendKeys("123456"); page.Send(); Wait(10).Until(ExpectedConditions.UrlMatches(Configuration.SITE_URL + "home/success")); }
public void TestLogin() { driver.Navigate().GoToUrl("http://localhost/litecart/admin/login.php"); driver.FindElement(By.Name("username")).SendKeys("admin"); driver.FindElement(By.Name("password")).SendKeys("admin"); driver.FindElement(By.Name("login")).Click(); wait.Until(ExpectedConditions.UrlMatches("http://localhost/litecart/admin/")); driver.FindElement(By.XPath("//ul[@id='box-apps-menu']/li[1]")).Click(); wait.Until(ExpectedConditions.TitleContains("Template")); driver.FindElement(By.XPath("//a[@title='Logout']")).Click(); wait.Until(ExpectedConditions.UrlMatches("http://localhost/litecart/admin/login.php")); }
protected bool CheckIfUrlMatches(string expectedUrlMatches, int timeoutS) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutS)); try { wait.Until(ExpectedConditions.UrlMatches(expectedUrlMatches)); return(true); } catch (WebDriverTimeoutException) { return(false); } }
public void WaitMessagesLoad() { var oldUrl = driver.Url; oldUrl = oldUrl.Replace("/", "\\/").Replace(".", "\\.").Replace("+", "\\+"); //min wait 1 sec; Thread.Sleep(1000); try { wait.Until(ExpectedConditions.UrlMatches($"^((?!{oldUrl}).)*$")); } catch { //same filters might be applied } }
public void GoNeaveInteractivePage() { WebDriverWait wait = new WebDriverWait(_webDriver, TimeSpan.FromSeconds(10)); var mainPage = new MainPage(_webDriver); mainPage.OpenPage(); mainPage.ClickNeaveInteractiveButton(); wait.Until(ExpectedConditions.UrlMatches("https://playtictactoe.org/#google_vignette")); var result = _webDriver.Url; Assert.AreEqual("https://playtictactoe.org/#google_vignette", result); }
public static void Execute(dynamic site, IWebDriver driver) { try { // Navigate to login page driver.Navigate().GoToUrl(site.Url + "pages/login.aspx"); var webDriverWait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); webDriverWait.Until(ExpectedConditions.UrlMatches(site.Url + "pages/login.aspx")); webDriverWait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete")); // check title Assert.AreEqual(site.Title, driver.Title); // TEST SUCCESSFUL LOGIN // click top sign in button var signinButtonLocator = By.XPath("//button[contains(@class, 'btn btn-accent exc-sign-in-btn')]"); webDriverWait.Until(DriverHelpers.ElementIsClickable(signinButtonLocator)); driver.FindElement(signinButtonLocator).Click(); // wait for elements to become visible (there are 2 sets of 2 elements that share the same id, so wait for one of them to become visible) webDriverWait.Until(ExpectedConditions.ElementIsVisible(By.Id("Username"))); webDriverWait.Until(ExpectedConditions.ElementIsVisible(By.Id("Password"))); var usernameElements = driver.FindElements(By.Id("Username")); var passwordElements = driver.FindElements(By.Id("Password")); // enter username do { usernameElements = driver.FindElements(By.Id("Username")); passwordElements = driver.FindElements(By.Id("Password")); }while (usernameElements.Count < 2 && passwordElements.Count < 2); driver.FindElements(By.Id("Username"))[1].SendKeys(site.User); //enter password driver.FindElements(By.Id("Password"))[1].SendKeys(site.Password); //click sign in button depending on which one is available driver.FindElement(By.XPath("//button[contains(@class, 'btn btn btn-primary exc-corner-btn')]")).Click(); webDriverWait.Until(ExpectedConditions.UrlMatches(site.Url + "MyAccount/MyBillUsage/pages/secure/MyBillUsage.aspx")); Assert.AreEqual(site.Url + "MyAccount/MyBillUsage/pages/secure/MyBillUsage.aspx", driver.Url); } catch { } }
public static void Execute(dynamic site, IWebDriver driver) { //await Task.Delay(1000); var webDriverWait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); // TEST SUCCESSFUL LOGIN // enter username try { webDriverWait.Until(ExpectedConditions.ElementIsVisible(By.Id("excNavLeft"))); driver.FindElements(By.ClassName("exc-nav-left-div-inactive"))[0].FindElement(By.ClassName("exc-nav-expand")).Click(); webDriverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//a[contains(text(), 'Pay with Bank Account')]"))); driver.FindElement(By.XPath("//a[contains(text(), 'Pay with Bank Account')]")).Click(); webDriverWait.Until(ExpectedConditions.UrlMatches(site.Url + "MyAccount/MyBillUsage/PayMyBill/Pages/secure/PayByECheck.aspx")); Assert.AreEqual(site.Url + "MyAccount/MyBillUsage/PayMyBill/Pages/secure/PayByECheck.aspx", driver.Url); } catch { } }
public void Registration() { WebDriverWait wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(10)); WebDriver.Navigate().GoToUrl("https://newbookmodels.com/join"); var firstName = WebDriver.FindElement(By.CssSelector("[name= first_name]")); firstName.SendKeys($"Valera{DateTime.Now.ToString("yyyyMMdhhmmss")}"); var lastName = WebDriver.FindElement(By.CssSelector("[name= last_name]")); lastName.SendKeys(($"Zmih{DateTime.Now.ToString("yyyyMMdhhmmss")}")); var email = WebDriver.FindElement(By.CssSelector("[name= email]")); email.SendKeys($"{DateTime.Now.ToString("yyyyMMdhhmmss")}@ukr.net"); var password = WebDriver.FindElement(By.CssSelector("[name= password]")); password.SendKeys("12345QWERTy_"); var passwordConfirm = WebDriver.FindElement(By.CssSelector("[name= password_confirm]")); passwordConfirm.SendKeys("12345QWERTy_"); var mobile = WebDriver.FindElement(By.CssSelector("[name=phone_number]")); mobile.SendKeys("5558883332"); var nextButton = WebDriver.FindElement(By.CssSelector("[class^=SignupForm__submitButton]")); nextButton.Click(); wait.Until(ExpectedConditions.UrlMatches("https://newbookmodels.com/join/company")); var result = WebDriver.Url; Assert.AreEqual("https://newbookmodels.com/join/company", result); }
public void NavigateToProducts_CreateProduct_WaitForRedirectAfterSuccess() { try { driver.Navigate().GoToUrl(localHostUrl); driver.FindElement(By.LinkText("Products")).Click(); string productsUrl = driver.Url.ToLower(); driver.FindElement(By.Id("CreateNewProduct")).Click(); IWebElement element = driver.FindElement(By.Id("Name")); element.SendKeys("Iphone 6"); element = driver.FindElement(By.Id("Producer")); element.SendKeys("Apple"); element = driver.FindElement(By.Id("Description")); element.SendKeys("Modern phone for modern people."); element = driver.FindElement(By.Id("Price")); element.SendKeys("13.45"); element = driver.FindElement(By.Id("Stock")); element.SendKeys("7"); driver.FindElement(By.Id("Submit")).Click(); WebDriverWait waiting = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); waiting.Until(ExpectedConditions.UrlMatches(productsUrl)); Assert.AreEqual(productsUrl, driver.Url.ToLower()); } catch (Exception e) { Debug.Print("Error: " + e); Assert.Fail(); } }
static Tuple <string, bool> WaitForNewPage(IWebDriver driver, IWebElement element, string url, int secondsForTimeout = 15) { WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, secondsForTimeout)); bool result = wait.Until(ExpectedConditions.StalenessOf(element)); if (result) { result = wait.Until(ExpectedConditions.UrlMatches(url)); if (result) { return(new Tuple <string, bool>("success | page change", true)); } else { return(new Tuple <string, bool>("failed | didn't reach target url", false)); } } else { return(new Tuple <string, bool>("failed | didn't leave page", false)); } }
public void signUpExistingAccount() { WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 10)); // navigate to desired page driver.Url = "http://a.testaddressbook.com/sign_up"; // Specify Data String email = "*****@*****.**"; String password = "******"; // wait for Email Field // fill out email field using `email` variable // fill out password field using `password` variable // click Sign Up button (or Submit Form) // Note that because this user already exists, Sign Up will not be successful wait.Until((ExpectedConditions.UrlMatches("http://a.testaddressbook.com/users"))); }
public void WholeProgram_NewParsingCorrectly_Test_01() { using (var driver = new ChromeDriver()) { /* Opening Configuration File and Loading Init Data */ if (File.Exists("configurationfile.xml") == false) { throw new Exception("Configuration file do not exists in the program's directory."); } XmlDocument configurationFile = new XmlDocument(); configurationFile.Load("configurationfile.xml"); string projectName = configurationFile.SelectSingleNode("//project").InnerText; string settingInProgess = configurationFile.SelectSingleNode("//setting").InnerText; if (projectName == String.Empty || settingInProgess == String.Empty) { throw new Exception(String.Format("At least one of the configuration arguments is empty. ProjectName: {0}, SettingName: {1}.", projectName, settingInProgess)); } /* Initializing the Driver and Navigating to TMS Home Page */ var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://tms.lionbridge.com/"); wait.Until(ExpectedConditions.UrlMatches("https://tms.lionbridge.com/")); /**/ TMSProjectsPage tmsProjectsPage = new TMSProjectsPage(driver); tmsProjectsPage.ClickChosenProject(projectName); TMSProjectHomePage tmsProjectHomePage = new TMSProjectHomePage(driver); tmsProjectHomePage.ChangeItemsPerPageToMinimum(driver); tmsProjectHomePage.StatusClick(); TMSStatusPage tmsStatusPage = new TMSStatusPage(driver); tmsStatusPage.AssingeeClick(); TMSAssigneesSubpage tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); tmsAssigneesSubpage.InitializeFiltersPanel(driver); if (tmsAssigneesSubpage.AssigneeCount == 1) { throw new Exception("Activities drop down list is empty. Program now will shut down. "); } tmsAssigneesSubpage.ChoseActivityOption(driver, "Translator_Translation_H"); tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); /*PageNavBar pageNavBar = new PageNavBar(driver); * * if (pageNavBar.ItemsPerPage != null) * { * pageNavBar.ItemsPerPage.ChoseDropDownOption(driver, "1000"); * }*/ tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); AssigneeList assigneeList = new AssigneeList(driver); List <AssigneeData> listAssigneeData = new List <AssigneeData>(); foreach (AssigneeItem assigneeItem in assigneeList.AssigneeItemsList) { listAssigneeData.Add(new AssigneeData(assigneeItem)); } assigneeList.TagSingleJob(driver, 0); tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); tmsAssigneesSubpage.LeftMenu.JobsView.ButtonClick(); wait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("r_L"))); JobList jobList = new JobList(driver); jobList.JobShowHistory(driver, 0); Assert.AreEqual(0, jobList.JobsItemsListCount); } }
//public static bool WaitingFor_UrlContains(IWebDriver driver, PageAlias alias) //{ // var uri = RouteMapper.ConvertAliasToUri(alias); // return WaitingFor_UrlContains(driver, uri); //} //public static bool WaitingFor_UrlToBe(IWebDriver driver, PageAlias alias, TimeSpan timeOut) //{ // var url = RouteMapper.ConvertAliasToUrl(alias); // var wait = new WebDriverWait(driver, timeOut); // return wait.Until(ExpectedConditions.UrlToBe(url)); //} //public static bool WaitingFor_UrlToBe(IWebDriver driver, PageAlias alias) //{ // return WaitingFor_UrlToBe(driver, alias, _timeoutInterval); //} public static bool WaitingFor_UrlMatches(IWebDriver driver, string regex, TimeSpan timeOut) { var wait = new WebDriverWait(driver, timeOut); return(wait.Until(ExpectedConditions.UrlMatches(regex))); }
public bool UrlContainsValidGuid() { return(ShortWait.Until(ExpectedConditions.UrlMatches(@"([0-9A-Fa-f]){8}-([0-9A-Fa-f]){4}-([0-9A-Fa-f]){4}-([0-9A-Fa-f]){4}-([0-9A-Fa-f]){12}"))); }
/// <summary> /// Pauses execution until the url matches a given string /// </summary> /// <param name="text">The text to use in comparison.</param> /// <returns>True if the URL matches the given text, false if the wait expires.</returns> public bool WaitForUrlToMatch(string text) { try { var wait = new WebDriverWait(Driver, Preferences.BaseSettings.Timeout).Until(ExpectedConditions.UrlMatches(text)); if (wait == false) { throw new Exception("URL does not appear within the timeout period."); } return(true); } catch (Exception) { return(false); } }
public void UrlToMatch(string regex) { new WebDriverWait(_webDriver, TimeSpan.FromMilliseconds(_waitMs)) .Until(ExpectedConditions.UrlMatches(regex)); }
public void SystemTest2() { using (var driver = new ChromeDriver()) { /* Opening Configuration File and Loading Init Data */ if (File.Exists("configurationfile.xml") == false) { throw new Exception("Configuration file do not exists in the program's directory."); } XmlDocument configurationFile = new XmlDocument(); configurationFile.Load("configurationfile.xml"); string projectName = configurationFile.SelectSingleNode("//project").InnerText; string settingInProgess = configurationFile.SelectSingleNode("//setting_inprogress").InnerText; string settingCompleted = configurationFile.SelectSingleNode("//setting_completed").InnerText; if (projectName == String.Empty || settingInProgess == String.Empty || settingCompleted == String.Empty) { throw new Exception(String.Format("At least one of the configuration arguments is empty. ProjectName: {0}, SettingInProgressName: {1}, SettingCompletedName: {2}", projectName, settingInProgess, settingCompleted)); } /* Initializing the Driver and Navigating to TMS Home Page */ var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://tms.lionbridge.com/"); wait.Until(ExpectedConditions.UrlMatches("https://tms.lionbridge.com/")); /**/ TMSProjectsPage tmsProjectsPage = new TMSProjectsPage(driver); tmsProjectsPage.ClickChosenProject(projectName); TMSProjectHomePage tmsProjectHomePage = new TMSProjectHomePage(driver); tmsProjectHomePage.ChangeItemsPerPageToMinimum(driver); tmsProjectHomePage.StatusClick(); TMSStatusPage tmsStatusPage = new TMSStatusPage(driver); tmsStatusPage.AssingeeClick(); TMSAssigneesSubpage tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); tmsAssigneesSubpage.InitializeFiltersPanel(driver); if (tmsAssigneesSubpage.AssigneeCount == 1) { throw new Exception("Activities drop down list is empty. Program now will shut down. "); } tmsAssigneesSubpage.ChoseActivityOption(driver, settingInProgess); tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); /*PageNavBar pageNavBar = new PageNavBar(driver); * * if (pageNavBar.ItemsPerPage != null) * { * pageNavBar.ItemsPerPage.ChoseDropDownOption(driver, "1000"); * }*/ tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); AssigneeList assigneeList = new AssigneeList(driver); List <AssigneeData> listAssigneeData = new List <AssigneeData>(); foreach (AssigneeItem assigneeItem in assigneeList.AssigneeItemsList) { listAssigneeData.Add(new AssigneeData(assigneeItem)); } assigneeList.TagAllJobs(driver); tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); tmsAssigneesSubpage.LeftMenu.JobsView.ButtonClick(); wait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("r_L"))); ButtonWait buttonWait = new ButtonWait(wait, ButtonWaitEnum.ProjectPageWait); buttonWait.WaitForConditions(); JobList jobList = new JobList(driver); foreach (AssigneeData assigneeData in listAssigneeData) { foreach (AssigneeDataElement assigneeDataElement in assigneeData.assigneeDataElements) { string jobName = assigneeDataElement.jobName.Trim(); jobList.JobShowHistory(driver, jobName); HistoryPopUp historyPopUp = new HistoryPopUp(driver); historyPopUp.InitializeFiltersPanel(driver); historyPopUp.ChoseSourceLanguageOption(driver, assigneeDataElement.sourceLanguage); historyPopUp.ChoseTargetLanguageOption(driver, assigneeDataElement.targetLanguage); historyPopUp.ChoseActivityOption(driver, settingCompleted); HistoryList historyList = new HistoryList(driver); assigneeDataElement.TranslatorName = historyList.HistoryItemsList[0].HistoryItemElements[0].StepCompletedBy; historyPopUp.CloseButtonClick(driver); } } //string path = Path.Combine(Directory.GetCurrentDirectory(), "TestFile.xlsx"); string path = Path.Combine(Directory.GetCurrentDirectory(), "TestFile.csv"); using (StreamWriter sw = new StreamWriter(path)) { string[] titles = { "Project Name: " + projectName, "Completed Step: " + settingCompleted, "Ongoing Step: " + settingInProgess }; string titlesLine = String.Join(";", titles); sw.WriteLine(titlesLine); string[] headers = { "Job Name", "Reviewer Name", "Translator Name", "Source Language", "Target Language", "WordCount", "Effort" }; string headersLine = String.Join(";", headers); sw.WriteLine(headersLine); foreach (var assigneeData in listAssigneeData) { foreach (var assigneeDataElement in assigneeData.assigneeDataElements) { string[] values = { assigneeDataElement.jobName, assigneeDataElement.reviewerName, assigneeDataElement.translatorName, assigneeDataElement.sourceLanguage, assigneeDataElement.targetLanguage, assigneeDataElement.wordcount, assigneeDataElement.effort }; string line = String.Join(";", values); sw.WriteLine(line); } } sw.Flush(); } } }
public void SystemTest() { using (var driver = new ChromeDriver()) { /* Opening Configuration File and Loading Init Data */ if (File.Exists("configurationfile.xml") == false) { throw new Exception("Configuration file do not exists in the program's directory."); } XmlDocument configurationFile = new XmlDocument(); configurationFile.Load("configurationfile.xml"); string projectName = configurationFile.SelectSingleNode("//project").InnerText; string settingInProgess = configurationFile.SelectSingleNode("//setting_inprogress").InnerText; string settingCompleted = configurationFile.SelectSingleNode("//setting_completed").InnerText; if (projectName == String.Empty || settingInProgess == String.Empty || settingCompleted == String.Empty) { throw new Exception(String.Format("At least one of the configuration arguments is empty. ProjectName: {0}, SettingInProgressName: {1}, SettingCompletedName: {2}", projectName, settingInProgess, settingCompleted)); } /* Initializing the Driver and Navigating to TMS Home Page */ var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://tms.lionbridge.com/"); wait.Until(ExpectedConditions.UrlMatches("https://tms.lionbridge.com/")); /**/ TMSProjectsPage tmsProjectsPage = new TMSProjectsPage(driver); tmsProjectsPage.ClickChosenProject(projectName); TMSProjectHomePage tmsProjectHomePage = new TMSProjectHomePage(driver); tmsProjectHomePage.ChangeItemsPerPageToMinimum(driver); tmsProjectHomePage.StatusClick(); TMSStatusPage tmsStatusPage = new TMSStatusPage(driver); tmsStatusPage.AssingeeClick(); TMSAssigneesSubpage tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); tmsAssigneesSubpage.InitializeFiltersPanel(driver); if (tmsAssigneesSubpage.AssigneeCount == 1) { throw new Exception("Activities drop down list is empty. Program now will shut down. "); } tmsAssigneesSubpage.ChoseActivityOption(driver, settingInProgess); tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); /*PageNavBar pageNavBar = new PageNavBar(driver); * * if (pageNavBar.ItemsPerPage != null) * { * pageNavBar.ItemsPerPage.ChoseDropDownOption(driver, "1000"); * }*/ tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); AssigneeList assigneeList = new AssigneeList(driver); List <AssigneeData> listAssigneeData = new List <AssigneeData>(); foreach (AssigneeItem assigneeItem in assigneeList.AssigneeItemsList) { listAssigneeData.Add(new AssigneeData(assigneeItem)); } assigneeList.AssigneeItemsList[0].AssigneeItemElements[0].TagSingleJob(driver); tmsAssigneesSubpage = new TMSAssigneesSubpage(driver); tmsAssigneesSubpage.LeftMenu.JobsView.ButtonClick(); wait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("r_L"))); JobList jobList = new JobList(driver); jobList.JobShowHistory(driver, 0); HistoryPopUp historyPopUp = new HistoryPopUp(driver); historyPopUp.InitializeFiltersPanel(driver); historyPopUp.ChoseSourceLanguageOption(driver, listAssigneeData[0].assigneeDataElements[0].sourceLanguage); historyPopUp.ChoseTargetLanguageOption(driver, listAssigneeData[0].assigneeDataElements[0].targetLanguage); historyPopUp.ChoseActivityOption(driver, settingCompleted); HistoryList historyList = new HistoryList(driver); //historyList.HistoryItemsList[0].HistoryItemElements[0].StepCompletedByClick(driver); listAssigneeData[0].assigneeDataElements[0].translatorName = historyList.HistoryItemsList[0].HistoryItemElements[0].StepCompletedBy; string path = Path.Combine(Directory.GetCurrentDirectory(), "TestFile.xlsx"); using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(path, SpreadsheetDocumentType.Workbook)) { // Add a WorkbookPart to the document. WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart(); workbookpart.Workbook = new Workbook(); // Add a WorksheetPart to the WorkbookPart. WorksheetPart worksheetPart = workbookpart.AddNewPart <WorksheetPart>(); worksheetPart.Worksheet = new Worksheet(new SheetData()); // Add Sheets to the Workbook. Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook. AppendChild <Sheets>(new Sheets()); // Append a new worksheet and associate it with the workbook. Sheet sheet = new Sheet() { Id = spreadsheetDocument.WorkbookPart. GetIdOfPart(worksheetPart), SheetId = 1, Name = "mySheet" }; sheets.Append(sheet); SheetData sheetData = worksheetPart.Worksheet.GetFirstChild <SheetData>(); UInt32 rowIndex = 0; foreach (var info in listAssigneeData) { var row = new Row() { RowIndex = rowIndex }; var firstNameCell = new Cell() { CellReference = "A" + (rowIndex + 1) }; firstNameCell.CellValue = new CellValue(info.assigneeDataElements[0].jobName); firstNameCell.DataType = CellValues.String; row.AppendChild(firstNameCell); Cell secondNameCell = new Cell() { CellReference = "B" + (rowIndex + 1) }; secondNameCell.CellValue = new CellValue(info.assigneeDataElements[0].sourceLanguage); secondNameCell.DataType = new EnumValue <CellValues>(CellValues.String); row.AppendChild(secondNameCell); Cell thirdNameCell = new Cell() { CellReference = "C" + (rowIndex + 1) }; thirdNameCell.CellValue = new CellValue(info.assigneeDataElements[0].targetLanguage); thirdNameCell.DataType = new EnumValue <CellValues>(CellValues.String); row.AppendChild(thirdNameCell); Cell fourthNameCell = new Cell() { CellReference = "D" + (rowIndex + 1) }; fourthNameCell.CellValue = new CellValue(info.assigneeDataElements[0].reviewerName); fourthNameCell.DataType = new EnumValue <CellValues>(CellValues.String); row.AppendChild(fourthNameCell); Cell fifthNameCell = new Cell() { CellReference = "E" + (rowIndex + 1) }; fifthNameCell.CellValue = new CellValue(info.assigneeDataElements[0].translatorName); fifthNameCell.DataType = new EnumValue <CellValues>(CellValues.String); row.AppendChild(fifthNameCell); Cell sixthNameCell = new Cell() { CellReference = "F" + (rowIndex + 1) }; sixthNameCell.CellValue = new CellValue(info.assigneeDataElements[0].effort); sixthNameCell.DataType = CellValues.String; row.AppendChild(sixthNameCell); Cell seventhNameCell = new Cell() { CellReference = "G" + (rowIndex + 1) }; seventhNameCell.CellValue = new CellValue(info.assigneeDataElements[0].wordcount); seventhNameCell.DataType = CellValues.String; row.AppendChild(seventhNameCell); sheetData.AppendChild(row); rowIndex++; } workbookpart.Workbook.Save(); } } }
private static void VerifyPageUrl(this IWebDriver webDriver, string value) { WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.UrlMatches(value)); }
public static void WaitForUrl(string url) { WebDriverWait wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(30)); wait.Until(ExpectedConditions.UrlMatches(url)); }