From 1ad66d6fb17bcf14d12fc8ca7fa9218419ad1665 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 10 May 2019 15:54:12 +0400 Subject: [PATCH] #103 change name method test --- src/test/java/IndexConferenceTest.java | 21 +++++++++++++++++++ src/test/java/conference/ConferencePage.java | 4 ++++ src/test/java/conference/ConferencesPage.java | 3 +++ 3 files changed, 28 insertions(+) diff --git a/src/test/java/IndexConferenceTest.java b/src/test/java/IndexConferenceTest.java index 9adf2f5..b3a4118 100644 --- a/src/test/java/IndexConferenceTest.java +++ b/src/test/java/IndexConferenceTest.java @@ -56,4 +56,25 @@ public class IndexConferenceTest extends TestTemplate { .stream() .anyMatch(webElement -> webElement.getText().equals(newConferenceName))); } + + @Test + public void testChangeConferenceNameAndSave() { + Map.Entry> page = Iterables.get(navigationHolder.entrySet(), 0); + + getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1)); + ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey()); + ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey()); + + conferencesPage.getConferenceFirst(); + String newConferenceName = "test " + (new Date()).getTime(); + conferencePage.clearName(); + conferencePage.setName(newConferenceName); + conferencePage.clickSaveBut(); + + Assert.assertTrue(conferencesPage.getConferencesList() + .stream() + .anyMatch(webElement -> webElement.getText().equals(newConferenceName))); + } + + } diff --git a/src/test/java/conference/ConferencePage.java b/src/test/java/conference/ConferencePage.java index 5f57008..48362e0 100644 --- a/src/test/java/conference/ConferencePage.java +++ b/src/test/java/conference/ConferencePage.java @@ -13,6 +13,10 @@ public class ConferencePage extends PageObject { driver.findElement(By.id("title")).sendKeys(name); } + public void clearName() { + driver.findElement(By.id("title")).clear(); + } + public void clickSaveBut() { driver.findElement(By.id("send-message-button")).click(); } diff --git a/src/test/java/conference/ConferencesPage.java b/src/test/java/conference/ConferencesPage.java index 0dc899d..b258420 100644 --- a/src/test/java/conference/ConferencesPage.java +++ b/src/test/java/conference/ConferencesPage.java @@ -14,6 +14,9 @@ public class ConferencesPage extends PageObject { public List getConferencesList() { return driver.findElements(By.cssSelector("span.h6.float-left.m-2")); + } + public void getConferenceFirst() { + driver.findElement(By.xpath("//*[@id=\"conferences\"]/div/div[2]/div[1]/div[1]/div/a")).click(); } } \ No newline at end of file