Repository: incubator-zeppelin Updated Branches: refs/heads/master e6447b256 -> 8e46b0a46
Add new selenium test case for create new paragraph button ### What is this PR for? Add a new test case for testing the create new button. Create new button is for creating new paragraph within notebook ### What type of PR is it? Test ### Is there a relevant Jira issue? NA ### How should this be tested? On OSX, you'll need firefox 42.0 installed, then you can run with PATH=~/Applications/Firefox.app/Contents/MacOS/:$PATH CI="" \ mvn -Dtest=org.apache.zeppelin.ParagraphActionsIT -Denforcer.skip=true \ test -pl zeppelin-server ### Questions: * Does the licenses files need update?NO * Is there breaking changes for older versions?NO * Does this needs documentation?NO Author: Ravi Ranjan <[email protected]> Closes #688 from ravicodder/testCreateNewButton and squashes the following commits: 7d5bc65 [Ravi Ranjan] Add LOG.error message in catch statement ce25396 [Ravi Ranjan] Add LOG.error in catch statement 0247d3f [Ravi Ranjan] Modified test case to test create new paragraph using '+' sign between paragraph 2fbf220 [Ravi Ranjan] modified Debug message and in checkthat value of pargarphs used instead of <true> or <false> 9b1d777 [Ravi Ranjan] Add new selenium test case for create new paragraph button Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/8e46b0a4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/8e46b0a4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/8e46b0a4 Branch: refs/heads/master Commit: 8e46b0a4604e85d0ab26c6ab27b6b962843a64f2 Parents: e6447b2 Author: Ravi Ranjan <[email protected]> Authored: Wed Feb 17 11:19:14 2016 +0530 Committer: Lee moon soo <[email protected]> Committed: Wed Feb 17 12:27:33 2016 -0800 ---------------------------------------------------------------------- .../integration/ParagraphActionsIT.java | 80 ++++++++++++++++++++ 1 file changed, 80 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8e46b0a4/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java index ddc7a4d..235c869 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java @@ -28,6 +28,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ErrorCollector; import org.openqa.selenium.*; +import org.openqa.selenium.interactions.Action; +import org.openqa.selenium.interactions.Actions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,6 +58,84 @@ public class ParagraphActionsIT extends AbstractZeppelinIT { driver.quit(); } + @Test + public void testCreateNewButton() throws InterruptedException { + if (!endToEndTestEnabled()) { + return; + } + try { + createNewNote(); + Actions action = new Actions(driver); + waitForParagraph(1, "READY"); + Integer oldNosOfParas = driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); + collector.checkThat("Before Insert New : the number of paragraph ", + oldNosOfParas, + CoreMatchers.equalTo(1)); + driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); + driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='insertNew()']")).click(); + waitForParagraph(2, "READY"); + Integer newNosOfParas = driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(); + collector.checkThat("After Insert New (using Insert New button) : number of paragraph", + oldNosOfParas + 1, + CoreMatchers.equalTo(newNosOfParas)); + + driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); + driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='removeParagraph()']")).click(); + ZeppelinITUtils.sleep(1000, false); + driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'delete this paragraph')]" + + "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); + ZeppelinITUtils.sleep(1000, false); + + WebElement oldParagraphEditor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")); + oldParagraphEditor.sendKeys(" original paragraph "); + + WebElement newPara = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class,'new-paragraph')][1]")); + action.moveToElement(newPara).click().build().perform(); + ZeppelinITUtils.sleep(1000, false); + waitForParagraph(1, "READY"); + + collector.checkThat("Paragraph is created above", + driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), + CoreMatchers.equalTo("")); + WebElement aboveParagraphEditor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")); + aboveParagraphEditor.sendKeys(" this is above "); + + newPara = driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class,'new-paragraph')][2]")); + action.moveToElement(newPara).click().build().perform(); + + waitForParagraph(3, "READY"); + + collector.checkThat("Paragraph is created below", + driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText(), + CoreMatchers.equalTo("")); + WebElement belowParagraphEditor = driver.findElement(By.xpath(getParagraphXPath(3) + "//textarea")); + belowParagraphEditor.sendKeys(" this is below "); + + collector.checkThat("The output field of paragraph1 contains", + driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), + CoreMatchers.equalTo(" this is above ")); + collector.checkThat("The output field paragraph2 contains", + driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), + CoreMatchers.equalTo(" original paragraph ")); + collector.checkThat("The output field paragraph3 contains", + driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText(), + CoreMatchers.equalTo(" this is below ")); + collector.checkThat("The current number of paragraphs after creating paragraph above and below", + driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(), + CoreMatchers.equalTo(3)); + + ZeppelinITUtils.sleep(1000, false); + deleteTestNotebook(driver); + + } catch (ElementNotVisibleException e) { + LOG.error("Exception in ParagraphActionsIT while testCreateNewButton ", e); + File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); + throw e; + + } + + + } @Test public void testMoveUpAndDown() throws Exception {
