Skip to content

Commit

Permalink
Add assert
Browse files Browse the repository at this point in the history
  • Loading branch information
PuzikovaV committed Sep 29, 2022
1 parent 200df79 commit 18170fc
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ Scenario: Sort by surname
| golub@student.com | password | | link@razdva.ru |
| yula@student.com | password | | link@razdva.ru |
| kraska@student.com | password | | link@razdva.ru |
Given Accept 3 homeworks and decline 2 in group "BlaBla" task "Apple"
| FirstName | LastName |
| Gennadiy | Krokodilov |
| Gennadiy | Bukin |
| Gennadiy | Golub |
| Gennadiy | Yula |
| Gennadiy | Akril |
#Given Accept 3 homeworks and decline 2 in group "BlaBla" task "Apple"
#| FirstName | LastName |
#| Gennadiy | Krokodilov |
#| Gennadiy | Bukin |
#| Gennadiy | Golub |
#| Gennadiy | Yula |
#| Gennadiy | Akril |
Given Open DevEdu web site https://piter-education.ru:7074/
Given Authorize user in service as teacher
| Email | Password |
| witch@teacher.com | password |
Given Teacher go to common progress
When Teacher sort students by surname
Then Students should sort by surname
| Name | Result |
| FullName | Result |
| Gennadiy Akril | Не сдано |
| Gennadiy Bukin | Сдано |
| Gennadiy Golub | Сдано |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class GeneralStudentsProgressTeacherPage:AbstractTeacherAuthorizedPage
public List<IWebElement> StudentsNames => _driver.FindElements(By.XPath($"//button[text()='Сортировать по фамилии']/../following-sibling::div")).ToList();
public List<IWebElement> AllResults => _driver.FindElements(By.XPath($"//div[@class='scroll-content-div']/div[2]/descendant::div[starts-with(@class,'one-block')]")).ToList();
public IWebElement BottomScrollBar => _driver.FindElement(By.XPath($"//div[contains(@class,'swiper-ini')][2]//div[@class='swiper-wrapper']"));
public IWebElement ButtonSortBySurname => _driver.FindElement(By.XPath($"//button[text()='Сортировать по фамилии']"));

public GeneralStudentsProgressTeacherPage()
{
Expand All @@ -27,5 +28,20 @@ public void ClickOnBottomScrollBar()
{
BottomScrollBar.Click();
}

public void ClickSortBySurname()
{
ButtonSortBySurname.Click();
}

public List<IWebElement> GetAllResults()
{
return _driver.FindElements(By.XPath($"//*[@class='one-block block-column']")).ToList();
}

public List<IWebElement> GetAllFullNames()
{
return _driver.FindElements(By.XPath($"//*[@class='one-block students-list']")).ToList();
}
}
}
6 changes: 1 addition & 5 deletions AutoTestsSelenium/PageObjects/JournalTeacherPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class JournalTeacherPage : AbstractTeacherAuthorizedPage
{
private const string PageUrl = $"{Urls.Host}/journal";
public List<IWebElement> StudentsNames => _driver.FindElements(By.XPath($"//*[text()='Сортировать по фамилии']/../following-sibling::div")).ToList();
public IWebElement ButtonSortBySurname => _driver.FindElement(By.XPath($"//button[text()='Сортировать по фамилии']"));

public JournalTeacherPage()
{
}
Expand All @@ -13,10 +13,6 @@ public override void OpenThisPage()
{
_driver.Navigate().GoToUrl(PageUrl);
}
public void ClickSortBySurname()
{
ButtonSortBySurname.Click();
}
public IWebElement GetDesiredGroupByName(string groupName)
{
return _driver.FindElement(By.XPath($"//*[text()='{groupName}']/.."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,43 @@ public class SortingInTheOverallProgressTabStepDefinitions
[Given(@"Teacher go to common progress")]
public void GivenTeacherGoToCommonProgress()
{
var journalTeacherPage = new JournalTeacherPage();
journalTeacherPage.ClickJournalButton();
var generalProgress = new GeneralStudentsProgressTeacherPage();
generalProgress.ClickGeneralProgressButton();
}

[When(@"Teacher sort students by surname")]
public void WhenTeacherSortStudentsBySurname()
{
var journalTeacherPage = new JournalTeacherPage();
journalTeacherPage.ClickSortBySurname();
var generalProgress = new GeneralStudentsProgressTeacherPage();
generalProgress.ClickSortBySurname();
}

[Then(@"Students should sort by surname")]
public void ThenStudentsShouldSortBySurname(Table table)
{
var generalProgress = new GeneralStudentsProgressTeacherPage();
List<StudentsHomeworkResultModel> studentsResults = table.CreateSet<StudentsHomeworkResultModel>().ToList();
List<string> expected = new List<string>();
foreach (var student in studentsResults)
{
expected.Add(student.FullName);
}
foreach (var student in studentsResults)
{
expected.Add(student.Result);
}
List<IWebElement> students = generalProgress.GetAllFullNames();
List<string> studentResult = new List<string>();
foreach (var student in students)
{
studentResult.Add(student.Text);
}
List<IWebElement> results = generalProgress.GetAllResults();
foreach (var result in results)
{
studentResult.Add(result.Text);
}
Assert.Equal(expected, studentResult);

}
}
Expand Down

0 comments on commit 18170fc

Please sign in to comment.