/// <summary> /// The set review property value. /// </summary> /// <param name="modelReviewProperty"> /// The model review property. /// </param> /// <param name="modelReviewValues"> /// The review value. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool SetReviewPropertyValue(ModelReviewProperties modelReviewProperty, ModelReviewValues modelReviewValues) { var criteriaText = modelReviewProperty.GetDisplayName(); var evaluationvalue = (int)modelReviewValues; var xPath = "(//p/span[text()='" + criteriaText + "']/../../following::div/anmeldelse_bedoemmelse_punkt[" + evaluationvalue + "])[1]"; StfLogger.LogDebug("criteria text xpath ", xPath); var retVal = WrapTrackWebShell.WebAdapter.Click(By.XPath(xPath)); if (!retVal) { StfLogger.LogError($"Couldn't find the criteria {modelReviewProperty}"); return(false); } WebAdapter.WaitForComplete(1); retVal = WebAdapter.Click(By.Id("butSaveReviewOneLang")); return(retVal); }
/// <summary> /// The logout. /// </summary> /// <param name="doCareAboutErrors"> /// Mostly used in close down scenarios - there we just want to close down - not really caring about success or not /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Logout(bool doCareAboutErrors = true) { if (CurrentLoggedInUser == null) { return(true); } CurrentLoggedInUser = null; try { if (WebAdapter.Click(By.XPath("//img[@alt='avatar']"))) { if (WebAdapter.Click(By.XPath("//a[@href='/Account/LogOff']"))) { return(true); } } if (doCareAboutErrors) { StfLogger.LogError("Got error while logging out"); } } catch { // slurp } // if we cant click the logout button, then the return value is down to if we care or not:-) return(doCareAboutErrors); }
/// <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> /// Open a registered brand. /// </summary> /// <param name="brandName"> /// The brand name. /// </param> /// <returns> /// The <see cref="IBrand"/>. /// </returns> public IBrand OpenRegisteredBrand(string brandName) { var xPath = $"//a[text()='{brandName}']"; var clicked = WebAdapter.Click(By.XPath(xPath)); var retVal = clicked ? Get <IBrand>() : default(IBrand); 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 logout. /// </summary> /// <param name="doCareAboutErrors"> /// Mostly used in close down scenarios - there we just want to close down - not really caring about success or not /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Logout(bool doCareAboutErrors = true) { try { if (WebAdapter.Click(By.Id("nav_logout"))) { return(true); } if (doCareAboutErrors) { StfLogger.LogError("Got error while logging out"); } } catch { // slurp } // if we cant click the logout button, then the return value is down to if we care or not:-) return(doCareAboutErrors); }