From 830f34b94f01b09bc5fc256c05830ecef1fc064c Mon Sep 17 00:00:00 2001 From: Prabhjyot Singh Date: Mon, 27 Jun 2016 13:08:38 +0530 Subject: [PATCH 1/3] add delay before checking the values --- .../integration/ParagraphActionsIT.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) 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 e07cdba0c8c..e48b990c87d 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 @@ -21,7 +21,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.zeppelin.AbstractZeppelinIT; import org.apache.zeppelin.WebDriverManager; -import org.apache.zeppelin.ZeppelinITUtils; import org.hamcrest.CoreMatchers; import org.junit.After; import org.junit.Before; @@ -80,16 +79,16 @@ public void testCreateNewButton() throws Exception { 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); + 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); + sleep(1000, false); setTextOfParagraph(1, " 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); + sleep(1000, false); waitForParagraph(1, "READY"); String oldIntpTag = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(); @@ -127,7 +126,7 @@ public void testCreateNewButton() throws Exception { driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(), CoreMatchers.equalTo(3)); - ZeppelinITUtils.sleep(1000, false); + sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { @@ -161,7 +160,7 @@ public void testRemoveButton() throws Exception { collector.checkThat("After Remove : Number of paragraphs are", oldNosOfParas-1, CoreMatchers.equalTo(newNosOfParas)); - ZeppelinITUtils.sleep(1000, false); + sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { @@ -198,7 +197,7 @@ public void testMoveUpAndDown() throws Exception { driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='moveDown()']")).click(); - ZeppelinITUtils.sleep(1000,false); + sleep(1000,false); collector.checkThat("The paragraph1 value contains", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), @@ -210,7 +209,7 @@ public void testMoveUpAndDown() throws Exception { driver.findElement(By.xpath(getParagraphXPath(2) + "//span[@class='icon-settings']")).click(); driver.findElement(By.xpath(getParagraphXPath(2) + "//ul/li/a[@ng-click='moveUp()']")).click(); - ZeppelinITUtils.sleep(1000,false); + sleep(1000,false); collector.checkThat("The paragraph1 value contains", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), @@ -218,7 +217,7 @@ public void testMoveUpAndDown() throws Exception { collector.checkThat("The paragraph1 value contains", driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), CoreMatchers.equalTo("2")); - ZeppelinITUtils.sleep(1000,false); + sleep(1000,false); deleteTestNotebook(driver); } catch (Exception e) { @@ -287,7 +286,7 @@ public void testClearOutputButton() throws Exception { collector.checkThat("After Clear Output field contains ", driver.findElement(By.xpath(xpathToOutputField)).getText(), CoreMatchers.equalTo("")); - ZeppelinITUtils.sleep(1000, false); + sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { @@ -342,21 +341,25 @@ public void testTitleButton() throws Exception { driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("")); driver.findElement(By.xpath(xpathToSettingIcon)).click(); + sleep(500, false); collector.checkThat("Before Show Title : The title option in option panel of paragraph is labeled as ", driver.findElement(By.xpath(xpathToShowTitle)).getText(), CoreMatchers.equalTo("Show title")); driver.findElement(By.xpath(xpathToShowTitle)).click(); + sleep(500, false); collector.checkThat("After Show Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("Untitled")); driver.findElement(By.xpath(xpathToSettingIcon)).click(); + sleep(500, false); collector.checkThat("After Show Title : The title option in option panel of paragraph is labeled as", driver.findElement(By.xpath(xpathToHideTitle)).getText(), CoreMatchers.equalTo("Hide title")); driver.findElement(By.xpath(xpathToHideTitle)).click(); + sleep(500, false); collector.checkThat("After Hide Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("")); @@ -365,15 +368,16 @@ public void testTitleButton() throws Exception { driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'title')]")).click(); driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).sendKeys("NEW TITLE" + Keys.ENTER); + sleep(500, false); collector.checkThat("After Editing the Title : The title field contains ", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("NEW TITLE")); driver.navigate().refresh(); - ZeppelinITUtils.sleep(1000, false); + sleep(1000, false); collector.checkThat("After Page Refresh : The title field contains ", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("NEW TITLE")); - ZeppelinITUtils.sleep(1000, false); + sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { @@ -414,7 +418,7 @@ public void testShowAndHideLineNumbers() throws Exception { collector.checkThat("After \"Hide line number\" the Line Number is Enabled", driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), CoreMatchers.equalTo(false)); - ZeppelinITUtils.sleep(1000, false); + sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { From bd5a641196e8dc276a7a2be051ae20e8afc3a6d9 Mon Sep 17 00:00:00 2001 From: Prabhjyot Singh Date: Mon, 27 Jun 2016 14:05:06 +0530 Subject: [PATCH 2/3] revert org.apache.zeppelin.ZeppelinITUtils --- .../integration/ParagraphActionsIT.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) 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 e48b990c87d..c523dc3bac7 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 @@ -21,6 +21,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.zeppelin.AbstractZeppelinIT; import org.apache.zeppelin.WebDriverManager; +import org.apache.zeppelin.ZeppelinITUtils; import org.hamcrest.CoreMatchers; import org.junit.After; import org.junit.Before; @@ -79,16 +80,16 @@ public void testCreateNewButton() throws Exception { driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='removeParagraph()']")).click(); - sleep(1000, false); + ZeppelinITUtils.sleep(1000, false); driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'delete this paragraph')]" + "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); - sleep(1000, false); + ZeppelinITUtils.sleep(1000, false); setTextOfParagraph(1, " original paragraph "); WebElement newPara = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class,'new-paragraph')][1]")); action.moveToElement(newPara).click().build().perform(); - sleep(1000, false); + ZeppelinITUtils.sleep(1000, false); waitForParagraph(1, "READY"); String oldIntpTag = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(); @@ -126,7 +127,7 @@ public void testCreateNewButton() throws Exception { driver.findElements(By.xpath("//div[@ng-controller=\"ParagraphCtrl\"]")).size(), CoreMatchers.equalTo(3)); - sleep(1000, false); + ZeppelinITUtils.sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { @@ -160,7 +161,7 @@ public void testRemoveButton() throws Exception { collector.checkThat("After Remove : Number of paragraphs are", oldNosOfParas-1, CoreMatchers.equalTo(newNosOfParas)); - sleep(1000, false); + ZeppelinITUtils.sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { @@ -197,7 +198,7 @@ public void testMoveUpAndDown() throws Exception { driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='moveDown()']")).click(); - sleep(1000,false); + ZeppelinITUtils.sleep(1000,false); collector.checkThat("The paragraph1 value contains", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), @@ -209,7 +210,7 @@ public void testMoveUpAndDown() throws Exception { driver.findElement(By.xpath(getParagraphXPath(2) + "//span[@class='icon-settings']")).click(); driver.findElement(By.xpath(getParagraphXPath(2) + "//ul/li/a[@ng-click='moveUp()']")).click(); - sleep(1000,false); + ZeppelinITUtils.sleep(1000,false); collector.checkThat("The paragraph1 value contains", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), @@ -217,7 +218,7 @@ public void testMoveUpAndDown() throws Exception { collector.checkThat("The paragraph1 value contains", driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'editor')]")).getText(), CoreMatchers.equalTo("2")); - sleep(1000,false); + ZeppelinITUtils.sleep(1000,false); deleteTestNotebook(driver); } catch (Exception e) { @@ -286,7 +287,7 @@ public void testClearOutputButton() throws Exception { collector.checkThat("After Clear Output field contains ", driver.findElement(By.xpath(xpathToOutputField)).getText(), CoreMatchers.equalTo("")); - sleep(1000, false); + ZeppelinITUtils.sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { @@ -341,25 +342,25 @@ public void testTitleButton() throws Exception { driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("")); driver.findElement(By.xpath(xpathToSettingIcon)).click(); - sleep(500, false); + ZeppelinITUtils.sleep(500, false); collector.checkThat("Before Show Title : The title option in option panel of paragraph is labeled as ", driver.findElement(By.xpath(xpathToShowTitle)).getText(), CoreMatchers.equalTo("Show title")); driver.findElement(By.xpath(xpathToShowTitle)).click(); - sleep(500, false); + ZeppelinITUtils.sleep(500, false); collector.checkThat("After Show Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("Untitled")); driver.findElement(By.xpath(xpathToSettingIcon)).click(); - sleep(500, false); + ZeppelinITUtils.sleep(500, false); collector.checkThat("After Show Title : The title option in option panel of paragraph is labeled as", driver.findElement(By.xpath(xpathToHideTitle)).getText(), CoreMatchers.equalTo("Hide title")); driver.findElement(By.xpath(xpathToHideTitle)).click(); - sleep(500, false); + ZeppelinITUtils.sleep(500, false); collector.checkThat("After Hide Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("")); @@ -368,16 +369,16 @@ public void testTitleButton() throws Exception { driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'title')]")).click(); driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).sendKeys("NEW TITLE" + Keys.ENTER); - sleep(500, false); + ZeppelinITUtils.sleep(500, false); collector.checkThat("After Editing the Title : The title field contains ", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("NEW TITLE")); driver.navigate().refresh(); - sleep(1000, false); + ZeppelinITUtils.sleep(1000, false); collector.checkThat("After Page Refresh : The title field contains ", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("NEW TITLE")); - sleep(1000, false); + ZeppelinITUtils.sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { @@ -418,7 +419,7 @@ public void testShowAndHideLineNumbers() throws Exception { collector.checkThat("After \"Hide line number\" the Line Number is Enabled", driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), CoreMatchers.equalTo(false)); - sleep(1000, false); + ZeppelinITUtils.sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { From 5eac352fc30b177951b0849db1a4acc45fe642af Mon Sep 17 00:00:00 2001 From: Prabhjyot Singh Date: Mon, 27 Jun 2016 17:12:28 +0530 Subject: [PATCH 3/3] use "clickAndWait" before all collector.checkThat/reading elements --- .../integration/ParagraphActionsIT.java | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) 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 f23020e7d45..95d55907251 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 @@ -204,9 +204,7 @@ public void testMoveUpAndDown() throws Exception { CoreMatchers.equalTo("2")); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='moveDown()']")).click(); - - ZeppelinITUtils.sleep(1000, false); + clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='moveDown()']")); collector.checkThat("The paragraph1 value contains", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), @@ -216,9 +214,7 @@ public void testMoveUpAndDown() throws Exception { CoreMatchers.equalTo("1")); driver.findElement(By.xpath(getParagraphXPath(2) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(2) + "//ul/li/a[@ng-click='moveUp()']")).click(); - - ZeppelinITUtils.sleep(1000, false); + clickAndWait(By.xpath(getParagraphXPath(2) + "//ul/li/a[@ng-click='moveUp()']")); collector.checkThat("The paragraph1 value contains", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(), @@ -247,7 +243,7 @@ public void testDisableParagraphRunButton() throws Exception { setTextOfParagraph(1, "println (\"abcd\")"); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='toggleEnableDisable()']")).click(); + clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='toggleEnableDisable()']")); collector.checkThat("The play button class was ", driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-control-play']")).isDisplayed(), CoreMatchers.equalTo(false) ); @@ -291,7 +287,8 @@ public void testClearOutputButton() throws Exception { driver.findElement(By.xpath(xpathToOutputField)).getText(), CoreMatchers.equalTo("abcd")); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); - driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='clearParagraphOutput()']")).click(); + clickAndWait(By.xpath(getParagraphXPath(1) + + "//ul/li/a[@ng-click='clearParagraphOutput()']")); collector.checkThat("After Clear Output field contains ", driver.findElement(By.xpath(xpathToOutputField)).getText(), CoreMatchers.equalTo("")); @@ -317,7 +314,7 @@ public void testWidth() throws Exception { driver.findElement(By.xpath("//div[contains(@class,'col-md-12')]")).isDisplayed(), CoreMatchers.equalTo(true)); for (Integer newWidth = 1; newWidth <= 11; newWidth++) { - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); + clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")); String visibleText = newWidth.toString(); new Select(driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/a/form/select[(@ng-change='changeColWidth()')]"))).selectByVisibleText(visibleText); @@ -349,26 +346,23 @@ public void testTitleButton() throws Exception { collector.checkThat("Before Show Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("")); - driver.findElement(By.xpath(xpathToSettingIcon)).click(); - ZeppelinITUtils.sleep(500, false); + + clickAndWait(By.xpath(xpathToSettingIcon)); collector.checkThat("Before Show Title : The title option in option panel of paragraph is labeled as ", driver.findElement(By.xpath(xpathToShowTitle)).getText(), CoreMatchers.equalTo("Show title")); - driver.findElement(By.xpath(xpathToShowTitle)).click(); - ZeppelinITUtils.sleep(500, false); + clickAndWait(By.xpath(xpathToShowTitle)); collector.checkThat("After Show Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("Untitled")); - driver.findElement(By.xpath(xpathToSettingIcon)).click(); - ZeppelinITUtils.sleep(500, false); + clickAndWait(By.xpath(xpathToSettingIcon)); collector.checkThat("After Show Title : The title option in option panel of paragraph is labeled as", driver.findElement(By.xpath(xpathToHideTitle)).getText(), CoreMatchers.equalTo("Hide title")); - driver.findElement(By.xpath(xpathToHideTitle)).click(); - ZeppelinITUtils.sleep(500, false); + clickAndWait(By.xpath(xpathToHideTitle)); collector.checkThat("After Hide Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("")); @@ -415,15 +409,15 @@ public void testShowAndHideLineNumbers() throws Exception { collector.checkThat("Before \"Show line number\" The option panel in paragraph has button labeled ", driver.findElement(By.xpath(xpathToShowLineNumberButton)).getText(), CoreMatchers.equalTo("Show line numbers")); - driver.findElement(By.xpath(xpathToShowLineNumberButton)).click(); + clickAndWait(By.xpath(xpathToShowLineNumberButton)); collector.checkThat("After \"Show line number\" the Line Number is Enabled ", driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), CoreMatchers.equalTo(true)); - driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); + clickAndWait(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")); collector.checkThat("After \"Show line number\" The option panel in paragraph has button labeled ", driver.findElement(By.xpath(xpathToHideLineNumberButton)).getText(), CoreMatchers.equalTo("Hide line numbers")); - driver.findElement(By.xpath(xpathToHideLineNumberButton)).click(); + clickAndWait(By.xpath(xpathToHideLineNumberButton)); collector.checkThat("After \"Hide line number\" the Line Number is Enabled", driver.findElement(By.xpath(xpathToLineNumberField)).isDisplayed(), CoreMatchers.equalTo(false));