Skip to content

Commit

Permalink
Modifying test cases such that they run independently. Adding a try c…
Browse files Browse the repository at this point in the history
…atch block in waitForLoading function to handle missing element error.

Signed-off-by: minurajeeve <[email protected]>
  • Loading branch information
minurajeeve committed Oct 14, 2023
1 parent 1b4457c commit ae87fc2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
18 changes: 16 additions & 2 deletions src/e2e-test/features/logviewer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
@Integration_Tests
Feature: Logviewer - Validate log viewer functionalities

@LOGVIEWER_TEST
Scenario: Deploy and run pipeline till complete
Background: Deploy and run pipeline
When Deploy and test pipeline "logs_generator" with timestamp with pipeline JSON file "logs_generator.json"
Then Run the pipeline
Then Deployed pipeline status is "Running"

@LOGVIEWER_TEST
Scenario: Deploy and run pipeline till complete
Then Deployed pipeline status is "Succeeded"

@LOGVIEWER_TEST
Scenario: Log viewer should show
Then Click on log viewer button
Expand All @@ -35,6 +38,7 @@ Feature: Logviewer - Validate log viewer functionalities

@LOGVIEWER_TEST
Scenario: Log level popover should work
Then Click on log viewer button
Then Click on log level toggle
Then Log level "ERROR" should exist
Then Log level "WARN" should exist
Expand All @@ -50,6 +54,7 @@ Feature: Logviewer - Validate log viewer functionalities

@LOGVIEWER_TEST
Scenario: Log viewer content should contain correct information
Then Click on log viewer button
Then Log viewer content should contain message "is started by user"
Then Log viewer content should not contain message "This is a WARN"
Then Click on advanced logs
Expand All @@ -61,12 +66,21 @@ Feature: Logviewer - Validate log viewer functionalities

@LOGVIEWER_TEST
Scenario: Log viewer should fetch next logs when scroll to bottom
Then Click on log viewer button
Then Click on advanced logs
Then Click on log level toggle
Then Click on log level "TRACE"
Then Scroll up to center
Then Scroll to latest should be enabled
Then Debug message should update

@LOGVIEWER_TEST
Scenario: Log viewer should fetch previous logs when scroll to top
Then Deployed pipeline status is "Succeeded"
Then Click on log viewer button
Then Click on advanced logs
Then Click on log level toggle
Then Click on log level "TRACE"
Then Scroll up to center
Then Click on scroll to latest button
Then Previous logs should show
10 changes: 10 additions & 0 deletions src/e2e-test/java/io/cdap/cdap/ui/stepsdesign/Logviewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ public void scrollUpToCenter() {
WebElement element = Helper.locateElementByCssSelector(
Helper.getCssSelectorByDataTestId("log-viewer-content")
);

Integer scrollHeight = Integer.valueOf(element.getDomProperty("scrollHeight"));
String heightInPixels = element.getCssValue("height");
Integer height = Integer.valueOf(heightInPixels.substring(0, heightInPixels.length() - 2));

//check if scrollbar is present
while (scrollHeight < height + 50 ){
Helper.waitSeconds(5);
scrollHeight = Integer.valueOf(element.getDomProperty("scrollHeight"));
}
js.executeScript("arguments[0].scrollBy(0, -1500);", element);
Commands.waitForLoading();
}
Expand Down
8 changes: 5 additions & 3 deletions src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,11 @@ public static JsonObject getPipelineStageJson(String stageName) {

public static void waitForLoading() {
if (Helper.isElementExists(Helper.getCssSelectorByDataTestId("loading-indicator"))) {
WaitHelper.waitForElementToBeHidden(
Helper.locateElementByCssSelector(Helper.getCssSelectorByDataTestId("loading-indicator"))
);
try {
WaitHelper.waitForElementToBeHidden(
Helper.locateElementByCssSelector(Helper.getCssSelectorByDataTestId("loading-indicator"))
);
} catch (Exception e) { }
}
}
}

0 comments on commit ae87fc2

Please sign in to comment.