Skip to content

Commit 1434b9f

Browse files
committed
Test fixes for cloud build
1 parent f3880b3 commit 1434b9f

7 files changed

Lines changed: 37 additions & 13 deletions

File tree

src/main/java/io/cdap/e2e/pages/actions/CdfStudioActions.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.slf4j.LoggerFactory;
3434

3535
import java.net.URISyntaxException;
36+
import java.time.Duration;
3637

3738
/**
3839
* Represents Cdf Studio Page Actions
@@ -105,6 +106,7 @@ public static void selectRealtimeSourcePlugin(String pluginName) {
105106
*/
106107
public static void verifyPluginNodeIsDisplayedOnCanvas(String pluginName, long timeoutInSeconds) {
107108
logger.info("Waiting for plugin : " + pluginName + " node to displayed on the canvas");
109+
WaitHelper.waitForPageToLoad();
108110
WaitHelper.waitForElementToBeDisplayed(CdfStudioLocators.locatePluginNodeInCanvas(pluginName), timeoutInSeconds);
109111
AssertionHelper.verifyElementDisplayed(CdfStudioLocators.locatePluginNodeInCanvas(pluginName)
110112
, "Plugin : " + pluginName + " node should be displayed on the canvas");
@@ -178,8 +180,9 @@ public static void fillPipelineNameAndSave(String pipelineName) {
178180
pipelineName();
179181
pipelineNameIp(pipelineName);
180182
pipelineSave();
181-
WaitHelper.waitForElementToBeDisplayed(CdfStudioLocators.statusBanner);
182-
WaitHelper.waitForElementToBeHidden(CdfStudioLocators.statusBanner);
183+
WaitHelper.waitForElementToBeOptionallyDisplayed(CdfStudioLocators.statusBannerDisplay(),
184+
ConstantsUtil.SMALL_TIMEOUT_SECONDS);
185+
WaitHelper.waitForElementToBeHidden(CdfStudioLocators.statusBannerDisplay(), ConstantsUtil.SMALL_TIMEOUT_SECONDS);
183186
}
184187

185188
/**
@@ -294,8 +297,10 @@ public static void verifyPipelinePreviewStatusInLogs(String status) {
294297
* Click on the Deploy button
295298
*/
296299
public static void pipelineDeploy() {
300+
WaitHelper.waitForPageToLoad();
297301
ElementHelper.clickOnElement(CdfStudioLocators.pipelineDeploy);
298-
WaitHelper.waitForElementToBeDisplayed(CdfStudioLocators.deployingPipelineMessage);
302+
WaitHelper.waitForElementToBeOptionallyDisplayed(CdfStudioLocators.locatorOfdeployingPipelineMessage(),
303+
ConstantsUtil.SMALL_TIMEOUT_SECONDS);
299304
WaitHelper.waitForElementToBeHidden(
300305
CdfStudioLocators.locatorOfdeployingPipelineMessage(), ConstantsUtil.PIPELINE_DEPLOY_TIMEOUT_SECONDS);
301306
}
@@ -532,7 +537,10 @@ public static void clickOnFixAllButtonIfDisplayed() {
532537
public static void importPipeline(String filePath) throws URISyntaxException {
533538
WaitHelper.waitForElementToBeDisplayed(CdfStudioLocators.importPipelineButton);
534539
FileImportUtil.uploadFile(CdfStudioLocators.importPipelineInputTag(), filePath);
540+
SeleniumDriver.getDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(50));
535541
clickOnFixAllButtonIfDisplayed();
542+
SeleniumDriver.getDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(40));
543+
WaitHelper.waitForPageToLoad();
536544
}
537545

538546
/**

src/main/java/io/cdap/e2e/pages/locators/CdfSignInLocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public By clickOnContinueButton() {
5151
}
5252

5353
public static By locatePluginNameInList(String pluginName, String pluginGroupName) {
54-
return By.xpath("//div[@data-cy='plugin-" + pluginGroupName + "-group']" +
54+
return By.xpath("//div[@data-testid='plugin-" + pluginGroupName + "-group']" +
5555
"//div[contains(@class, 'PluginNameContainer')][normalize-space(text()) = '" + pluginName + "' " +
5656
"or translate(normalize-space(text()),' ','') = '" + pluginName + "']");
5757
}

src/main/java/io/cdap/e2e/pages/locators/CdfStudioLocators.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ public static By locateDataPipelineTypeSelectedOption(String option) {
171171
}
172172

173173
public static WebElement locatePluginGroupExpanded(String pluginGroupName) {
174-
String xpath = "//div[@data-cy='plugin-" + pluginGroupName + "-group-summary' and @aria-expanded='true']";
174+
String xpath = "//div[@data-testid='plugin-" + pluginGroupName + "-group-summary' and @aria-expanded='true']";
175175
return SeleniumDriver.getDriver().findElement(By.xpath(xpath));
176176
}
177177

178178
public static By locatorOfPluginGroupCollapsed(String pluginGroupName) {
179-
String xpath = "//div[@data-cy='plugin-" + pluginGroupName + "-group-summary' and @aria-expanded='false']";
179+
String xpath = "//div[@data-testid='plugin-" + pluginGroupName + "-group-summary' and @aria-expanded='false']";
180180
return By.xpath(xpath);
181181
}
182182

@@ -185,19 +185,19 @@ public static WebElement locatePluginGroupCollapsed(String pluginGroupName) {
185185
}
186186

187187
public static WebElement locatePluginNameInList(String pluginName, String pluginGroupName) {
188-
String xpath = "//div[@data-cy='plugin-" + pluginGroupName + "-group']" +
188+
String xpath = "//div[@data-testid='plugin-" + pluginGroupName + "-group']" +
189189
"//div[contains(@class, 'PluginNameContainer')][normalize-space(text()) = '" + pluginName + "' " +
190190
"or translate(normalize-space(text()),' ','') = '" + pluginName + "']";
191191
return SeleniumDriver.getDriver().findElement(By.xpath(xpath));
192192
}
193193

194194
public static WebElement locateSinkPluginNameInList(String pluginName) {
195-
String xpath = "//*[@data-cy='plugin-" + pluginName + "-batchsink']";
195+
String xpath = "//*[@data-testid='plugin-" + pluginName + "-batchsink']";
196196
return SeleniumDriver.getDriver().findElement(By.xpath(xpath));
197197
}
198198

199199
public static WebElement locateRealtimeSourcePluginNameInList(String pluginName) {
200-
String xpath = "//*[@data-cy='plugin-" + pluginName + "-streamingsource']";
200+
String xpath = "//*[@data-testid='plugin-" + pluginName + "-streamingsource']";
201201
return SeleniumDriver.getDriver().findElement(By.xpath(xpath));
202202
}
203203

@@ -273,7 +273,11 @@ public static By locatorOfLoadingSpinnerOnValidateButton() {
273273
public static WebElement importPipelineButton;
274274

275275
public static By fixAllButton() {
276-
return By.xpath("//button[@data-cy='fix-all-btn']");
276+
return By.xpath("//button[@data-testid='fix-all-btn']");
277+
}
278+
279+
public static By statusBannerDisplay() {
280+
return By.xpath("//*[@data-cy='valium-banner-hydrator']");
277281
}
278282

279283
public static WebElement importPipelineInputTag() {

src/main/java/io/cdap/e2e/utils/CdfHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030
import org.openqa.selenium.By;
3131
import org.openqa.selenium.WebElement;
3232
import org.openqa.selenium.support.ui.ExpectedConditions;
33+
import org.openqa.selenium.support.ui.Wait;
3334
import org.openqa.selenium.support.ui.WebDriverWait;
3435
import stepsdesign.BeforeActions;
3536

3637
import java.io.IOException;
38+
import java.time.Duration;
3739
import java.util.HashMap;
3840
import java.util.Map;
3941
import java.util.UUID;
@@ -61,9 +63,12 @@ default void openCdf() throws IOException, InterruptedException {
6163
CdfSignInActions.login();
6264
PageHelper.acceptAlertIfPresent();
6365
WaitHelper.waitForPageToLoad();
66+
PageHelper.refreshCurrentPage();
67+
WaitHelper.waitForPageToLoad();
6468
}
6569

6670
/* TODO: Remove below wait once https://cdap.atlassian.net/browse/CDAP-18862 is fixed */
71+
SeleniumDriver.getDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(60));
6772
WaitHelper.waitForElementToBeDisplayed(
6873
CdfStudioLocators.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source"));
6974
}

src/main/java/io/cdap/e2e/utils/ConstantsUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ public class ConstantsUtil {
8383
/**
8484
* DEFAULT_TIMEOUT_SECONDS: To be used in external wait helpers defined in {@link WaitHelper}
8585
*/
86-
public static final int DEFAULT_TIMEOUT_SECONDS = 180;
86+
public static final int DEFAULT_TIMEOUT_SECONDS = 300;
8787
/**
8888
* PAGE_LOAD_TIMEOUT_SECONDS: To be used as Selenium driver's default page load timeout
8989
*/
90-
public static final int PAGE_LOAD_TIMEOUT_SECONDS = 50;
90+
public static final int PAGE_LOAD_TIMEOUT_SECONDS = 300;
9191
/**
9292
* SMALL_TIMEOUT_SECONDS: To be used as a small static wait (only if needed)
9393
*/
94-
public static final int SMALL_TIMEOUT_SECONDS = 5;
94+
public static final int SMALL_TIMEOUT_SECONDS = 20;
9595
/**
9696
* MEDIUM_TIMEOUT_SECONDS: To be used as a medium static wait (only if needed)
9797
*/

src/main/java/io/cdap/e2e/utils/WaitHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ public static boolean waitForElementToBeOptionallyDisplayed(By locator, long tim
138138
} catch (StaleElementReferenceException e) {
139139
logger.info("Element is not interactable");
140140
return false;
141+
} catch (TimeoutException e) {
142+
logger.info("Element not found withing timeout");
143+
return false;
141144
}
142145
}
143146

src/main/java/stepsdesign/PipelineSteps.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import io.cdap.e2e.utils.CdfHelper;
2525
import io.cdap.e2e.utils.ConstantsUtil;
2626
import io.cdap.e2e.utils.PluginPropertyUtils;
27+
import io.cdap.e2e.utils.SeleniumDriver;
2728
import io.cdap.e2e.utils.SeleniumHelper;
29+
import io.cdap.e2e.utils.WaitHelper;
2830
import io.cucumber.datatable.DataTable;
2931
import io.cucumber.java.en.Given;
3032
import io.cucumber.java.en.Then;
@@ -36,6 +38,7 @@
3638

3739
import java.io.IOException;
3840
import java.net.URISyntaxException;
41+
import java.time.Duration;
3942
import java.util.ArrayList;
4043
import java.util.HashMap;
4144
import java.util.List;
@@ -104,6 +107,7 @@ public void selectRealtimeSourcePlugin(String pluginName) {
104107

105108
@Then("Verify plugin: {string} node is displayed on the canvas with a timeout of {long} seconds")
106109
public void verifyPluginNodeIsDisplayedOnTheCanvas(String pluginName, long timeoutInSeconds) {
110+
SeleniumDriver.getDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(35));
107111
CdfStudioActions.verifyPluginNodeIsDisplayedOnCanvas(pluginName, timeoutInSeconds);
108112
}
109113

0 commit comments

Comments
 (0)