public void DeleteArticleFromAnotherAuthor() { // Arange var userPath = Path.GetFullPath(directoryPath + "/Jsons/LoginUserWithValidCredentials.json"); var user = ActiveUser.FromJson(File.ReadAllText(userPath)); var secondUserPath = Path.GetFullPath(directoryPath + "/Jsons/LoginSecondUserWithValidCredentials.json"); var secondUser = ActiveUser.FromJson(File.ReadAllText(secondUserPath)); var articlePath = Path.GetFullPath(directoryPath + "/Jsons/ArticleWithValidData_DeleteTest_AnotherAuthor.json"); var article = Article.FromJson(File.ReadAllText(articlePath)); // Act driver.Navigate().GoToUrl(loginPage.Url); loginPage.LogIn(user); homePage.CreateButton.Click(); createArticlePage.CreateArticleForm(article); homePage.LogOffButton.Click(); driver.Navigate().GoToUrl(loginPage.Url); loginPage.LogIn(secondUser); IWebElement deleteArticle = driver.FindElement(By.LinkText(article.Title)); deleteArticle.Click(); articleMainPage.DeleteButton.Click(); // Assert Assert.That(articleMainPage.ErrorMsg.Text.Contains("You can't delete article from another user.")); }
public void LoginWithValidCredentials(string testCase) { // Arange var userPath = Path.GetFullPath(directoryPath + "/Jsons/LoginUserWithValidCredentials.json"); var user = ActiveUser.FromJson(File.ReadAllText(userPath)); // Act driver.Navigate().GoToUrl(loginPage.Url); loginPage.LogIn(user); // Assert switch (testCase) { case "Login": Assert.That(homePage.HelloButton.Displayed); break; case "Logout": homePage.LogOffButton.Click(); Assert.That(homePage.LogInButton.Displayed); break; default: break; } }
public void DeleteArticleAsAuthor() { // Arange var userPath = Path.GetFullPath(directoryPath + "/Jsons/LoginUserWithValidCredentials.json"); var user = ActiveUser.FromJson(File.ReadAllText(userPath)); var articlePath = Path.GetFullPath(directoryPath + "/Jsons/ArticleWithValidData_DeleteTest.json"); var article = Article.FromJson(File.ReadAllText(articlePath)); // Act driver.Navigate().GoToUrl(loginPage.Url); loginPage.LogIn(user); homePage.CreateButton.Click(); createArticlePage.CreateArticleForm(article); IWebElement deleteArticle = driver.FindElement(By.LinkText(article.Title)); deleteArticle.Click(); articleMainPage.DeleteButton.Click(); articleDeletePage.DeleteButton.Click(); List <string> allArticleTitles = new List <string>(); foreach (var title in homePage.AllArticleTitles) { allArticleTitles.Add(title.Text); } // Assert Assert.False(allArticleTitles.Contains(article.Title), "The article is still here: " + article.Title); }
public void CreateArticleWithValidData() { // Arange var userPath = Path.GetFullPath(directoryPath + "/Jsons/LoginUserWithValidCredentials.json"); var user = ActiveUser.FromJson(File.ReadAllText(userPath)); var articlePath = Path.GetFullPath(directoryPath + "/Jsons/ArticleWithValidData.json"); var article = Article.FromJson(File.ReadAllText(articlePath)); // Act driver.Navigate().GoToUrl(loginPage.Url); loginPage.LogIn(user); homePage.CreateButton.Click(); createArticlePage.CreateArticleForm(article); List <string> allArticleTitles = new List <string>(); foreach (var title in homePage.AllArticleTitles) { allArticleTitles.Add(title.Text); } // Assert Assert.That(allArticleTitles.Contains(article.Title)); }
public void ChangePasswordWithInvalidData(string jsonFileName) { // Arange var userPath = Path.GetFullPath(directoryPath + $"/Jsons/{jsonFileName}.json"); var user = ActiveUser.FromJson(File.ReadAllText(userPath)); // Act driver.Navigate().GoToUrl(loginPage.Url); loginPage.LogIn(user); homePage.HelloButton.Click(); profilePage.ChangePasswordButton.Click(); profilePage.ChangePasswordForm(user); profilePage.SubmitButton.Click(); // Assert string errorMessage = ""; switch (jsonFileName) { case "ChangePasswordWithEmptyNewPassword": errorMessage = "The New password field is required."; break; case "ChangePasswordWithWrongConfirmationPassword": errorMessage = "The new password and confirmation password do not match."; break; default: break; } Assert.That(profilePage.ErrorMsg.Text.Contains($"{errorMessage}")); }
public void ChangePasswordWithValidData() { // Arange var userPath = Path.GetFullPath(directoryPath + "/Jsons/ChangePasswordWithValidData.json"); var userPathRestore = Path.GetFullPath(directoryPath + "/Jsons/ChangePasswordWithValidData_Restore.json"); var user = ActiveUser.FromJson(File.ReadAllText(userPath)); var userRestore = ActiveUser.FromJson(File.ReadAllText(userPathRestore)); //var passwordChange = new SwapPasswordsAfterPasswordChange(); //passwordChange.SwapPasswords(userPath); // Act driver.Navigate().GoToUrl(loginPage.Url); loginPage.LogIn(user); homePage.HelloButton.Click(); profilePage.ChangePasswordButton.Click(); profilePage.ChangePasswordForm(user); profilePage.SubmitButton.Click(); //Restore original Password homePage.HelloButton.Click(); profilePage.ChangePasswordButton.Click(); profilePage.ChangePasswordForm(userRestore); profilePage.SubmitButton.Click(); // Assert Assert.That(homePage.HelloButton.Displayed); }
public void LoginWithInvalidCredentials() { // Arange var userPath = Path.GetFullPath(directoryPath + "/Jsons/LoginUserWithInvalidCredentials.json"); var user = ActiveUser.FromJson(File.ReadAllText(userPath)); // Act driver.Navigate().GoToUrl(loginPage.Url); loginPage.LogIn(user); var environmentName = System.Environment.MachineName; // Assert Assert.That(loginPage.ErrorMsg.Text.Contains("Invalid login attempt.")); }
public void CreateArticleWithInValidData(string jsonFileName) { // Arange var userPath = Path.GetFullPath(directoryPath + "/Jsons/LoginUserWithValidCredentials.json"); var user = ActiveUser.FromJson(File.ReadAllText(userPath)); var articlePath = Path.GetFullPath(directoryPath + $"/Jsons/{jsonFileName}.json"); var article = Article.FromJson(File.ReadAllText(articlePath)); // Act driver.Navigate().GoToUrl(loginPage.Url); loginPage.LogIn(user); homePage.CreateButton.Click(); createArticlePage.CreateArticleForm(article); // Assert string errorMessage = ""; switch (jsonFileName) { case "ArticleWithInValidContent": errorMessage = "The Content field is required."; break; case "ArticleWithInValidTitle": errorMessage = "The Title field is required."; break; case "ArticleWithEmptyData": errorMessage = "The Title field is required.\r\nThe Content field is required."; break; default: break; } Assert.That(createArticlePage.ErrorMsg.Text.Contains($"{errorMessage}")); }