/// <summary> /// The choose english. /// </summary> private void ChooseEnglish() { const string Xpath = @"//sprog_valg//img[@src=""http://wt.troldvaerk.org/grafik/flag/2.svg""]"; WebAdapter.ButtonClickByXpath(Xpath); WebAdapter.WaitForComplete(1); }
/// <summary> /// The upload picture. /// </summary> /// <param name="localPathToImage"> /// The local path to image. /// </param> /// <returns> /// Indication of success. /// </returns> public bool UploadPicture(string localPathToImage) { var buttonClickAdminPictures = WebAdapter.ButtonClickByXpath("(//button[@id='but_adm_pic'])[2]"); if (!buttonClickAdminPictures) { return(false); } WebAdapter.WaitForComplete(3); // handle the File Upload Dialog var nativeDialogFileUpload = WebAdapter.NativeDialogFileUpload(By.Id("userfile"), localPathToImage); if (!nativeDialogFileUpload) { return(false); } WebAdapter.WaitForComplete(3); // Press upload the image var buttonClickUploadImage = WebAdapter.ButtonClickById("but_doupload"); if (!buttonClickUploadImage) { return(false); } WebAdapter.WaitForComplete(3); return(true); }
/// <summary> /// The go menu. /// </summary> /// <param name="menuName"> /// The menu name. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> private bool GoMenu(string menuName) { var xpath = $"//div[@class='submenu2']/a[text()='{menuName}']"; var retVal = WebAdapter.ButtonClickByXpath(xpath); return(retVal); }
/// <summary> /// The learn more. /// </summary> /// <returns> /// Indication of success /// </returns> /// <summary> /// The login. /// </summary> /// <param name="userName"> /// The user name. /// </param> /// <param name="password"> /// The password. /// </param> public bool Login(string userName = null, string password = null) { // Handle defaults for username password userName = HandleDefault(userName, BtoWebConfiguration.UserName); password = HandleDefault(password, BtoWebConfiguration.Password); // CLick the login if (!WebAdapter.Click(By.XPath("//a[@href='/Account/Login']"))) { StfLogger.LogError("Couldn't press login"); return(false); } // fill in credentials WebAdapter.TextboxSetTextById("Email", userName); WebAdapter.TextboxSetTextById("password", password); // Click tab page Login WebAdapter.ButtonClickByXpath("//button[text()='Log in']"); // Remember the last logged in user CurrentLoggedInUser = userName; return(true); }
/// <summary> /// Gets or sets the all. /// </summary> /// <returns> /// The <see cref="IAllBrands"/>. /// </returns> public IAllBrands All() { var clicked = WebAdapter.ButtonClickByXpath("//a[normalize-space()='all']"); var retVal = clicked ? Get <IAllBrands>() : null; return(retVal); }
/// <summary> /// The select and open brand. /// </summary> /// <param name="brandName"> /// The brand name. /// </param> /// <returns> /// The <see cref="IBrand"/>. /// </returns> public IBrand SelectAndOpenBrand(string brandName) { var xpath = $"//p[normalize-space()='{brandName.Trim()}']/../div"; var clicked = WebAdapter.ButtonClickByXpath(xpath); var retVal = clicked ? Get <IBrand>() : null; return(retVal); }
/// <summary> /// The delete model. /// </summary> /// <param name="modelNameToDelete"> /// The model name to delete. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool DeleteModel(string modelNameToDelete) { // Press administration var retVal = WebAdapter.ButtonClickById("admin"); if (!retVal) { return(false); } // open the right pattern var xPath = $"//a[text()='{modelNameToDelete}']"; retVal = WebAdapter.Click(By.XPath(xPath)); if (!retVal) { return(false); } // Press delete retVal = WebAdapter.ButtonClickById("deleteModel"); if (!retVal) { return(false); } // Yeap I'm sure retVal = WebAdapter.ButtonClickById("okDeleteModel"); if (!retVal) { return(false); } // Exit Admin mode retVal = WebAdapter.ButtonClickByXpath("//button[normalize-space()='Show']"); if (!retVal) { return(false); } return(true); }
/// <summary> /// The add model. /// </summary> /// <param name="modelName"> /// The model name. /// </param> /// <param name="pattern"> /// The pattern. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool AddModel(string modelName, string pattern = null) { const string AddModelXpath = "//span/span[text()='Add model']"; var retVal = WebAdapter.ButtonClickByXpath(AddModelXpath); if (!retVal) { return(false); } // if pattern is null, then create model without pattern if (string.IsNullOrEmpty(pattern)) { pattern = "--- without pattern ---"; } const string PatternNameXpath = "//p[normalize-space()='Pattern']/../..//select"; retVal = WebAdapter.SelectElementSetText(By.XPath(PatternNameXpath), pattern); if (!retVal) { return(false); } const string ModelNameXpath = "//p[normalize-space()='Model']/../..//input"; retVal = WebAdapter.TextboxSetTextByXpath(ModelNameXpath, modelName); if (!retVal) { return(false); } retVal = WebAdapter.ButtonClickById("create"); if (!retVal) { return(false); } // Yeap done retVal = WebAdapter.ButtonClickById("modelDone"); return(retVal); }
/// <summary> /// Pass on the wrap to user 'username' (only possible for owner of wrap) /// </summary> /// <param name="username"> /// The username. /// </param> /// <param name="ownershipStart"> /// The ownership Start. /// If not set, default date is used /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool PassOn(string username, string ownershipStart = null) { // click the Pass On Button in the menu if (!WebAdapter.ButtonClickByXpath("//button[@id='but_passon']")) { StfLogger.LogDebug("Couldn't press PassOn button"); return(false); } if (!WebAdapter.TextboxSetTextById("inputBrugerSoeg", username, true)) { StfLogger.LogDebug("Couldn't set brugerSoeg text"); return(false); } // click the select user button if (!WebAdapter.ButtonClickById("but_selUser")) { StfLogger.LogDebug("Couldn't press SelectUser button"); return(false); } // Choose a date for ownership-start if (ownershipStart != null) { WebAdapter.WaitForComplete(TimeSpan.FromSeconds(1)); if (!WebAdapter.TextboxSetTextById("inp_datePassOn", ownershipStart)) { StfLogger.LogInfo("Date for ownership not changed"); return(false); } } // answer the R U sure if (!WebAdapter.ButtonClickById("but_goPassOn")) { StfLogger.LogDebug("Couldn't press R-U-Sure button"); return(false); } return(true); }
/// <summary> /// The review. /// </summary> /// <returns> /// The <see cref="IReview"/>. /// </returns> public IReview Review() { try { var buttonClick = WebAdapter.ButtonClickByXpath("(//button//span[text()='Review'])[2]"); // var buttonClick = WebAdapter.ButtonClickById("butAddReview"); if (!buttonClick) { return(null); } var reviewDetails = Get <IReview>(); return(reviewDetails); } catch (Exception ex) { StfLogger.LogError($"Something went wrong when opening Review. Message : [{ex.Message}]"); throw; } }
/// <summary> /// The send away temporarily. /// </summary> /// <param name="sendAwayReason"> /// The send away reason. /// </param> /// <param name="recipient"> /// The recipient. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool SendAwayTemporarily(SendAwayReason sendAwayReason, string recipient) { string inputValue; // click the SendAwayTemp button WebAdapter.ButtonClickById("but_sendonholiday"); switch (sendAwayReason) { case SendAwayReason.Holiday: inputValue = "ferie"; break; case SendAwayReason.Tester: inputValue = "test"; break; case SendAwayReason.Rent: inputValue = "udlejning"; break; default: throw new ArgumentOutOfRangeException(nameof(sendAwayReason), sendAwayReason, null); } var xPath = $"//input[@value='{inputValue}']"; WebAdapter.ButtonClickByXpath(xPath); // now chose the recipient WebAdapter.TextboxSetTextById("inputBrugerSoeg_ferievikle", recipient, true); WebAdapter.ButtonClickById("but_chooseUser"); // press ok var retVal = WebAdapter.ButtonClickById("but_ok1_vaelg"); return(retVal); }