public bool CheckShowFullLessDesignNameActionLinkBehaviors(bool needShowFullName) { DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.XPath("//div[contains(@class, 'fblw-timeline-item')]"))); try { if (needShowFullName) { DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Show full name"))).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Show less"))).Click(); return(true); } DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Show less"))).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Show full name"))).Click(); return(true); } catch { return(false); } }
public List <IWebElement> DownloadButtons() { var downloadButtons = DriverContext.BrowserWait().Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy( By.XPath("//div[@id='componentInfo']//ul[@class='product-activities']//li//button[@ng-click='downloadDesign(action.jobName)']"))); return(downloadButtons.ToList()); }
public string GetDesignName(string expectedName = null) { if (string.IsNullOrEmpty(expectedName)) { return(DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class='product-title']//h2"))).Text); } else { var designName = string.Empty; void getDesignName() { var i = 0; do { designName = DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class='product-title']//h2"))).Text; if (designName.IsEquals(expectedName)) { break; } Thread.Sleep(1000); i++; } while (i < 3); } getDesignName(); return(designName); } }
public bool CheckIfItIsLongText() { var designNameElement = DriverContext.BrowserWait() .Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class='product-title']//h2"))); return(false); }
public string GetSelectedComponentName(bool isKit) { if (!isKit) { return(string.Empty); } return(DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class='dropdown']//button"))).Text.Trim()); }
public void DoSearchAndWaitResults(string designName) { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.Id("products"))); DriverContext.Driver.ScrollToTop(); var txtSearch = DriverContext.Driver.FindElement(By.Id("txtDesignSearch")); txtSearch.Clear(); txtSearch.SendKeys(designName); DriverContext.Driver.FindElement(By.Id("doSearching")).Click(); }
public bool CheckDesignCanGoToActionPage(string designName) { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.Id("products"))); var element = DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable( By.XPath($"//div[@data-documentname='{designName}']//div[@class='thumbnail']"))); var actions = new Actions(DriverContext.Driver); actions.MoveToElement(element).Perform(); return(DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath($"//div[@data-documentname='{designName}']//div[@class='thumbnail']//div[@class='content-wrapper']//ul//li[@class='inactive']//a[@name='go']"))) == null); }
public void DoSort(string optionName) { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class='dropdown']"))); //we should not use actions.MoveToEelement in this case because the dropdown location is incorrect since more data loaded by paging DriverContext.Driver.ScrollToTop(); DriverContext.Driver.FindElement(By.XPath("//div[@class='dropdown']//button[contains(@class, 'dropdown')]")).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class='dropdown open']"))); DriverContext.Driver.FindElement(By.LinkText(optionName)).Click(); }
public void ClickToEditDesign(string documentName) { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.Id("products"))); var element = DriverContext.BrowserWait(35).Until(ExpectedConditions.ElementToBeClickable(By.XPath($"//div[@data-documentname='{documentName}']//div[@class='thumbnail']"))); var actions = new Actions(DriverContext.Driver); actions.MoveToElement(element).Perform(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath($"//div[@data-documentname='{documentName}']//div[@class='thumbnail']//div[@class='content-wrapper']//ul//li//a[@name='edit']"))).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.UrlContains("UserEditFormFilling")); }
public void SubmitApprovalWorkflow() { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath("//button[@ng-click='submitForApproval()']"))).Click(); //verify modal visibility DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.ClassName("modal-open"))); //agree publish design DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//li//button[@ng-click='submitForApproval()']"))).Click(); //verify modal is closed DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.ClassName("modal-open"))); Thread.Sleep(2000); }
public string[] GetDesignNames() { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.Id("products"))); var designs = DriverContext.Driver .FindElements( By.XPath("//div[@class='thumbnail']//div[@class='caption']//div[@class='caption-container']//h4")); if (designs.Any()) { return(designs.Select(x => x.Text).ToArray()); } return(new string[] { }); }
public bool CheckShowFullLessDesignNameActionLinkVisibility(bool visibilityExpectation, bool needShowFullName = true) { DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.XPath("//div[contains(@class, 'fblw-timeline-item')]"))); if (visibilityExpectation) { if (needShowFullName) { return(DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Show full name"))) != null); } return(DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Show less"))) != null); } return(Driver.FindElements(By.LinkText("Show less")).Any()); }
public string RenameDesign(string name) { DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.XPath("//div[contains(@class, 'fblw-timeline-item')]"))); DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//a[@ng-click='renameDesign()']"))).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.ClassName("modal-open"))); var textField = DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.Name("designName"))); textField.Clear(); if (!string.IsNullOrEmpty(name)) { textField.SendKeys(name); } Console.WriteLine("run to here 1!!!"); //wait to renameDesign button ready for clicking DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.XPath("//button[contains(@class, 'disabled')]"))); DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[@ng-click='renameDesign()']"))).Click(); var messageElement = Driver.FindElements(By.XPath("//p[contains(@class, 'text-danger')]")).FirstOrDefault(); if (messageElement != null) { var message = messageElement.Text; DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[@ng-click='$dismiss()']"))).Click(); //verify modal is closed DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.ClassName("modal-open"))); Driver.RefreshPage(); return(message); } //verify modal is closed DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.ClassName("modal-open"))); Console.WriteLine("run to here 2!!!"); Driver.RefreshPage(); return(string.Empty); }
public bool DoCopyDesign(string designName, string copiedDesignName) { DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath($"//div[@data-documentname='{designName}']//div[@class='thumbnail']//div[@class='content-wrapper']//ul//li//a[@name='copy']"))).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.ClassName("modal-open"))); var textField = DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.Name("designName"))); textField.Clear(); textField.SendKeys(copiedDesignName); DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[@ng-click='cloneDesign()']"))).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.ClassName("modal-open"))); return(CheckDesignExists(copiedDesignName)); }
public string CheckValidDesignNameWhenRenaming(string designName) { var renameButton = DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.LinkText("Rename"))); renameButton.Click(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.ClassName("modal-open"))); var textField = DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.Name("designName"))); textField.Clear(); textField.SendKeys(designName); //wait until it's show error message if invalid design name return(string.Empty); }
public void DownloadDesign(bool needToPublishFirst, ref bool isShowSurveyInvitationModal) { var downloadButtons = DownloadButtons(); foreach (var button in downloadButtons) { button.Click(); if (needToPublishFirst) { needToPublishFirst = false; //verify modal visibility DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.ClassName("modal-open"))); //agree publish design DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[@ng-click='createDesign()']"))).Click(); //verify modal is closed DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.ClassName("modal-open"))); } } //TakeSurveyIfVisible(isShowSurveyInvitationModal);//TODO if (isShowSurveyInvitationModal) { isShowSurveyInvitationModal = false; } //wait until all download buttons are show checked icon void makeSureAllOutputsAreDownloaded(int expectedNumber) { var downloadedButtonsCount = DriverContext.BrowserWait().Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy( By.XPath("//div[@id='componentInfo']//ul[@class='product-activities']//li//button[contains(@class, 'downloaded')]"))).Count; if (downloadedButtonsCount != expectedNumber) { makeSureAllOutputsAreDownloaded(expectedNumber); } } makeSureAllOutputsAreDownloaded(downloadButtons.Count); //DisplayCompletedDownloadModal(); }
public void CheckGoToActions(string documentName) { if (DriverContext.Driver.IsUrlEndsWith("onedesign")) { return; } DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.Id("products"))); var element = DriverContext.BrowserWait(35).Until(ExpectedConditions.ElementToBeClickable(By.XPath($"//div[@data-documentname='{documentName}']//div[@class='thumbnail']"))); var actions = new Actions(DriverContext.Driver); actions.MoveToElement(element).Perform(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath($"//div[@data-documentname='{documentName}']//div[@class='thumbnail']//div[@class='content-wrapper']//ul//li//a[@name='go']"))).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.UrlContains("onedesign")); }
public bool CheckDeleteDocumentAction(string documentName) { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.Id("products"))); var element = DriverContext.BrowserWait(35).Until(ExpectedConditions.ElementToBeClickable( By.XPath($"//div[contains(@data-documentname, '{documentName}')]//div[@class='thumbnail']"))); var actions = new Actions(DriverContext.Driver); actions.MoveToElement(element).Perform(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath($"//div[contains(@data-documentname, '{documentName}')]//div[@class='thumbnail']//div[@class='content-wrapper']//ul//li//a[@name='delete']"))).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.ClassName("modal-open"))); DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[@ng-click='deleteDesign()']"))).Click(); DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.ClassName("modal-open"))); return(!CheckDesignExists(documentName)); }
public string GetDesignStatus(string designName) { var result = string.Empty; void getStatus(string name) { var i = 0; do { try { DriverContext.BrowserWait() .Until(ExpectedConditions.ElementIsVisible( By.XPath($"//div[@data-documentname='{name}']"))); var element = DriverContext.BrowserWait(3).Until(ExpectedConditions.ElementIsVisible( By.XPath( $"//div[@data-documentname='{name}']//div[@class='thumbnail']//div[@class='content-wrapper']//div[contains(@class, 'design-info')]//span"))); result = element.Text; break; } catch (Exception ex) { Console.WriteLine($"Design name: {designName}; exception details: {ex}"); } i++; DriverContext.Driver.RefreshPage(); } while (i < 3); } getStatus(designName); return(result); }
public int CountDesignsByStatus(int expectedNumber, string status) { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.Id("products"))); var designsByStatusCount = 0; var tryingTime = 0; do { designsByStatusCount = DriverContext.Driver.FindElements(By.XPath("//div[@class='thumbnail']//div[@class='content-wrapper']//div[contains(@class, 'design-info')]//span")).Where(x => x.Text.IsEquals(status)).Count(); if (designsByStatusCount == expectedNumber) { break; } tryingTime++; Thread.Sleep(1000); } while (tryingTime < 5); return(designsByStatusCount); }
public bool DoPaging() { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.Id("products"))); var elements = DriverContext.Driver.FindElements(By.Id("paging")); if (elements.Any() && elements.FirstOrDefault().Displayed) { var button = DriverContext.Driver.FindElement(By.XPath("//div[@id='paging']//div/button")); var actions = new Actions(DriverContext.Driver); actions.MoveToElement(button); button.Click(); DriverContext.BrowserWait().Until(ExpectedConditions.InvisibilityOfElementLocated(By.XPath("//div[@id='paging']//div//button[contains(@class, 'pressed')]"))); Thread.Sleep(2000); return(true); } return(false); }
public string GetRetiredOrDeletedLabel(string designName) { return(DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath($"//div[@data-documentname='{designName}']//div[@class='thumbnail']//div[@class='content-wrapper']//label"))).Text); }
public string GetNoDesignsMessage() { return(DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[contains(@class, 'no-designs-wrapper')]//h4"))).Text); }
public int CountDesignsByStatus(string status) { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.Id("products"))); return(DriverContext.Driver.FindElements(By.XPath("//div[@class='thumbnail']//div[@class='content-wrapper']//div[contains(@class, 'design-info')]//span")).Where(x => x.Text.IsEquals(status)).Count()); }
public bool IsDisplayedHyperlinkMore() { return(DriverContext.BrowserWait().Until(ExpectedConditions.ElementExists(By.Id("designTitleDisplayMngLink"))).Displayed); }
public void BackToMyDesign() { DriverContext.BrowserWait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@class='rmui-breadcrumb']//a[contains(@href, '#/designs')]"))).Click(); }
public string GetSelectedSortingOption() { DriverContext.BrowserWait().Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class='dropdown']"))); return(DriverContext.Driver.FindElement(By.XPath("//div[@class='dropdown']//button[contains(@class, 'dropdown')]")).Text); }