Подскажите, пожалуйста, как избежать повторений открытия страницы MainPage в тестах, как здесь, например:
@Test
public void IsTheActualTitleEqualledToTheExpectedTitle() {
String command = "git config --global user.name \"New Sheriff in Town\"" +
"\ngit reset $(git commit-tree HEAD^{tree} -m \"Legacy code\")" +
"\ngit push origin master --force";
MainPage mainPage = new MainPage(driver)
.openPage()
.clickNewPasteBtn()
.inputTextArea(command)
.selectPastSyntaxHighlightingFromDropDownList("Bash")
.selectPasteExpirationFromDropDownList("10 Minutes")
.inputTitle("how to gain dominance among developers")
.clickCreateNewPasteBtn();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class = 'info-top']/h1")));
String actualResult = driver.findElement(By.xpath("//div[@class = 'info-top']/h1")).getText();
Assert.assertEquals(actualResult, "how to gain dominance among developers");
}
@Test
public void IsTheActualSyntaxEqualledToTheExpectedSyntax() {
String command = "git config --global user.name \"New Sheriff in Town\"" +
"\ngit reset $(git commit-tree HEAD^{tree} -m \"Legacy code\")" +
"\ngit push origin master --force";
MainPage mainPage = new MainPage(driver)
.openPage()
.clickNewPasteBtn()
.inputTextArea(command)
.selectPastSyntaxHighlightingFromDropDownList("Bash")
.selectPasteExpirationFromDropDownList("10 Minutes")
.inputTitle("how to gain dominance among developers")
.clickCreateNewPasteBtn();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[text() = 'Bash']")));
String actualResult = driver.findElement(By.xpath("//a[text() = 'Bash']")).getText();
Assert.assertEquals(actualResult, "Bash");
}
@Test
public void IsTheActualCommandsEqalledToTheExpectedCommands() {
String command = "git config --global user.name \"New Sheriff in Town\"" +
"\ngit reset $(git commit-tree HEAD^{tree} -m \"Legacy code\")" +
"\ngit push origin master --force";
MainPage mainPage = new MainPage(driver)
.openPage()
.clickNewPasteBtn()
.inputTextArea(command)
.selectPastSyntaxHighlightingFromDropDownList("Bash")
.selectPasteExpirationFromDropDownList("10 Minutes")
.inputTitle("how to gain dominance among developers")
.clickCreateNewPasteBtn();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//ol[@class='bash']")));
String actualResult = driver.findElement(By.xpath("//ol[@class='bash']")).getText();
Assert.assertEquals(command, actualResult);
}
Благодарю за подсказки.