Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitCLI committed Oct 28, 2024
1 parent 460e47e commit 7da3736
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 94 deletions.
180 changes: 121 additions & 59 deletions src/main/java/io/cdap/e2e/pages/actions/WranglerActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,55 +61,72 @@ public static void selectDirectiveAndOption(String columnName, String directive,
throws InterruptedException {
ElementHelper.clickOnElement(WranglerLocators.locateTransformationButton(columnName));
String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive);
String pluginPropertyDirectiveOption = PluginPropertyUtils.getPluginPropertyElementTestId(option);
switch (directive) {

case "CustomTransform":
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
ElementHelper.sendKeysToTextarea(WranglerLocators.filterTextArea, option);
ElementHelper.clickOnElement(WranglerLocators.applyButton);
ElementHelper.sendKeysToTextarea(WranglerLocators.enterTextArea(pluginPropertyDirective), option);
ElementHelper.clickOnElement(WranglerLocators.applyButton(pluginPropertyDirective));
break;

case "MaskData":
case "Explode":
ElementHelper.hoverOverElement(WranglerLocators.scrollButton);
WaitHelper.waitForElementToBeDisplayed(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOptionsTag(pluginPropertyDirective,
pluginPropertyDirectiveOption));
break;

case "Filter":
case "Sendtoerror":
case "SendToError":
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
Select selectDropdown = new Select(WranglerLocators.filterSelect);
ElementHelper.scrollToElementUsingJsExecutor(WranglerLocators.selectDirectiveOption(option));
selectDropdown.selectByVisibleText(option);
ElementHelper.clickOnElement(WranglerLocators.applyButton);
Select selectDropdown = new Select(WranglerLocators.selectDropdownOption(pluginPropertyDirective));
ElementHelper.scrollToElementUsingJsExecutor(WranglerLocators.
selectFilterOptions(pluginPropertyDirective,
pluginPropertyDirectiveOption));
selectDropdown.selectByVisibleText(PluginPropertyUtils.pluginProp("filterEmptyProperty"));
ElementHelper.clickOnElement(WranglerLocators.applyButton(pluginPropertyDirective));
break;

case "FillNullOrEmptyCells":
case "CopyColumn":
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
ElementHelper.replaceElementValue(WranglerLocators.enterText, option);
ElementHelper.clickOnElement(WranglerLocators.applyButton);
if (directive.equals("FillNullOrEmptyCells")) {
ElementHelper.replaceElementValue(WranglerLocators.enterText(pluginPropertyDirective), option);
} else {
ElementHelper.replaceElementValue(WranglerLocators.enterText(pluginPropertyDirective), option);
}
ElementHelper.clickOnElement(WranglerLocators.applyButton(pluginPropertyDirective));
break;

case "Hash":
ElementHelper.hoverOverElement(WranglerLocators.scrollButton);
WaitHelper.waitForElementToBeDisplayed(WranglerLocators.scrollButtonDisabled);
WaitHelper.waitForElementToBeDisplayed(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
Select select = new Select(WranglerLocators.filterSelect);
ElementHelper.scrollToElementUsingJsExecutor(WranglerLocators.selectDirectiveOption(option));
Select select = new Select(WranglerLocators.selectDropdownOption(pluginPropertyDirective));
ElementHelper.scrollToElementUsingJsExecutor(WranglerLocators.selectHashOption(option));
select.selectByVisibleText(option);
ElementHelper.clickOnElement(WranglerLocators.applyButton);
ElementHelper.clickOnElement(WranglerLocators.applyButton(pluginPropertyDirective));
break;

case "Decode":
case "Encode":
ElementHelper.hoverOverElement(WranglerLocators.scrollButton);
WaitHelper.waitForElementToBeDisplayed(WranglerLocators.scrollButtonDisabled);
WaitHelper.waitForElementToBeDisplayed(WranglerLocators.encodeDirective);
if (directive.equals("Encode")) {
ElementHelper.clickOnElement(WranglerLocators.encodeDirective);
} else {
ElementHelper.clickOnElement(WranglerLocators.decodeDirective);
}
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(option));
ElementHelper.clickOnElement(WranglerLocators.encodeDecodeOptions(option));
break;

default:
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(option));
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective
, pluginPropertyDirectiveOption));
}

}
Expand All @@ -130,7 +147,7 @@ public static void selectDirectiveTypeWithDropdownAndText(String columnName, Str
String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive);
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));

if (pluginPropertyDirective.equals("findAndReplace")) {
if (directive.equals("FindAndReplace")) {
ElementHelper.sendKeys(WranglerLocators.enterOldValue, directiveType);
ElementHelper.sendKeys(WranglerLocators.enterNewValue, text);
ElementHelper.clickOnElement(WranglerLocators.replaceAllButton);
Expand All @@ -143,15 +160,26 @@ public static void selectDirectiveTypeWithDropdownAndText(String columnName, Str
case "value starts with":
case "value ends with":
case "value matches regex":
Select select = new Select(WranglerLocators.filterSelect);
Select select = new Select(WranglerLocators.selectDropdownOption(pluginPropertyDirective));
select.selectByVisibleText(directiveType);
ElementHelper.sendKeysToTextarea(WranglerLocators.enterText, text);
if (directive.equals("Filter")) {
ElementHelper.sendKeysToTextarea(WranglerLocators.enterText(pluginPropertyDirective), text);
} else if (directive.equals("SendToError")) {
ElementHelper.sendKeysToTextarea(WranglerLocators.enterText(pluginPropertyDirective), text);
}
ElementHelper.clickOnElement(WranglerLocators.applyButton(pluginPropertyDirective));
break;

case "Custom condition":
Select selectCustom = new Select(WranglerLocators.filterSelect);
selectCustom.selectByVisibleText(directiveType);
ElementHelper.sendKeysToTextarea(WranglerLocators.filterTextArea, text);
if (directive.equals("Filter")) {
Select selectCustom = new Select(WranglerLocators.selectDropdownOption(pluginPropertyDirective));
selectCustom.selectByVisibleText(directiveType);
ElementHelper.sendKeysToTextarea(WranglerLocators.enterTextArea(pluginPropertyDirective), text);
} else if (directive.equals("SendToError")) {
Select selectCustom = new Select(WranglerLocators.selectDropdownOption(pluginPropertyDirective));
selectCustom.selectByVisibleText(directiveType);
ElementHelper.sendKeysToTextarea(WranglerLocators.enterTextArea(pluginPropertyDirective), text);
}
break;
}
}
Expand All @@ -163,45 +191,73 @@ public static void selectDirectiveTypeWithThreeOptions(String columnName, String
throws InterruptedException {
ElementHelper.clickOnElement(WranglerLocators.locateTransformationButton(columnName));
String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive);
String pluginPropertyDirectiveOption = PluginPropertyUtils.getPluginPropertyElementTestId(directiveType);
String optionType = PluginPropertyUtils.getPluginPropertyElementTestId(option);
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(directiveType));

switch (directiveType) {
case "Decimal":
ElementHelper.sendKeys(WranglerLocators.scaleText, option);
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective,
pluginPropertyDirectiveOption));
ElementHelper.sendKeys(WranglerLocators.scaleText, optionType);
ElementHelper.clickOnElement(WranglerLocators.applyButtonUppercase);
break;

case "Character count":
ElementHelper.replaceElementValue(WranglerLocators.enterText, option);
ElementHelper.clickOnElement(WranglerLocators.applyButton);
case "CSV":
case "LOG":
case "SIMPLEDATE":
case "DATETIME":
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective, directiveType));
ElementHelper.clickOnElement(WranglerLocators.parseModalOption(pluginPropertyDirective,
pluginPropertyDirectiveOption, optionType));
ElementHelper.clickOnElement(WranglerLocators.parseModalApplyButton(pluginPropertyDirectiveOption));
break;

case "Character_count":
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective,
pluginPropertyDirectiveOption));
ElementHelper.replaceElementValue(WranglerLocators.enterText(pluginPropertyDirective), optionType);
ElementHelper.clickOnElement(WranglerLocators.subMenuApplyButton(pluginPropertyDirective));
break;

case "FIXEDLENGTH":
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective, directiveType));
ElementHelper.sendKeys(WranglerLocators.columnWidths, optionType);
ElementHelper.clickOnElement(WranglerLocators.parseModalApplyButton(pluginPropertyDirectiveOption));
break;

case "Fixed length":
ElementHelper.sendKeys(WranglerLocators.columnWidths, option);
ElementHelper.clickOnElement(WranglerLocators.applyButton);
case "XMLTOJSON":
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective, directiveType));
ElementHelper.replaceElementValue(WranglerLocators.enterDepthXmlToJson, optionType);
ElementHelper.clickOnElement(WranglerLocators.parseModalApplyButton(pluginPropertyDirectiveOption));
break;

case "XML to JSON":
case "JSON":
ElementHelper.replaceElementValue(WranglerLocators.enterDepth, option);
ElementHelper.clickOnElement(WranglerLocators.applyButton);
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective, directiveType));
ElementHelper.replaceElementValue(WranglerLocators.enterDepthJson, optionType);
ElementHelper.clickOnElement(WranglerLocators.parseModalApplyButton(pluginPropertyDirectiveOption));
break;

case "Excel":
ElementHelper.replaceElementValue(WranglerLocators.excelSheetNumber, option);
ElementHelper.clickOnElement(WranglerLocators.applyButton);
case "EXCEL":
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective, directiveType));
ElementHelper.replaceElementValue(WranglerLocators.excelSheetNumber, optionType);
ElementHelper.clickOnElement(WranglerLocators.parseModalApplyButton(pluginPropertyDirectiveOption));
break;

case "Using patterns":
ElementHelper.clickOnElement(WranglerLocators.selectPattern);
ElementHelper.clickOnElement(WranglerLocators.selectOptionForPatterns(option));
ElementHelper.clickOnElement(WranglerLocators.extractButton);
case "Using_patterns":
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOptionsTag(pluginPropertyDirective,
pluginPropertyDirectiveOption));
ElementHelper.clickOnElement(WranglerLocators.selectPatternButton);
ElementHelper.clickOnElementUsingJsExecutor(WranglerLocators.selectOptionForPatterns(optionType));
ElementHelper.clickOnElement(WranglerLocators.extractFieldsApplyButton(pluginPropertyDirectiveOption));
break;

default:
ElementHelper.clickOnElement(WranglerLocators.selectRadioButton(option));
ElementHelper.clickOnElement(WranglerLocators.applyButton);
case "Using_delimiters":
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOptionsTag(pluginPropertyDirective,
pluginPropertyDirectiveOption));
ElementHelper.clickOnElement(WranglerLocators.selectDelimiterOptions(option));
ElementHelper.clickOnElement(WranglerLocators.extractFieldsApplyButton(pluginPropertyDirectiveOption));
break;
}
}

Expand All @@ -220,32 +276,37 @@ public static void selectDirectiveTypeWithFourOption(String columnName, String d
throws InterruptedException {
ElementHelper.clickOnElement(WranglerLocators.locateTransformationButton(columnName));
String pluginPropertyDirective = PluginPropertyUtils.getPluginPropertyElementTestId(directive);
String pluginPropertyDirectiveOption = PluginPropertyUtils.getPluginPropertyElementTestId(directiveType);
String optionType = PluginPropertyUtils.getPluginPropertyElementTestId(option);
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
switch (directiveType) {
case "Concatenate":
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(directiveType));
ElementHelper.sendKeys(WranglerLocators.enterText, text);
Select selectDropdown = new Select(WranglerLocators.filterSelect);
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective,
pluginPropertyDirectiveOption));
ElementHelper.sendKeys(WranglerLocators.enterText(pluginPropertyDirective), text);
Select selectDropdown = new Select(WranglerLocators.selectDropdownOption(pluginPropertyDirective));
selectDropdown.selectByVisibleText(option);
ElementHelper.clickOnElementUsingJsExecutor(WranglerLocators.selectDirectiveOption(option));
ElementHelper.clickOnElement(WranglerLocators.subMenuApplyButton(pluginPropertyDirective));
break;

case "Datetime":
case "Simple date":
if (option.equals("Custom format")) {
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(directiveType));
ElementHelper.clickOnElement(WranglerLocators.selectRadioButton(option));
case "SIMPLEDATE":
case "DATETIME":
ElementHelper.clickOnElement(WranglerLocators.selectDirectiveOption(pluginPropertyDirective, directiveType));
if (option.equals("Custom_Format")) {
ElementHelper.clickOnElement(WranglerLocators.parseModalOption(pluginPropertyDirective,
pluginPropertyDirectiveOption, optionType));
ElementHelper.sendKeys(WranglerLocators.customDate, text);
ElementHelper.clickOnElement(WranglerLocators.parseModalApplyButton(pluginPropertyDirectiveOption));
}
break;
case "Always":
Select select = new Select(WranglerLocators.filterSelect);
Select select = new Select(WranglerLocators.selectDropdownOption(pluginPropertyDirective));
select.selectByVisibleText(directiveType);
ElementHelper.sendKeysToTextarea(WranglerLocators.enterCounterName, text);
ElementHelper.replaceElementValue(WranglerLocators.incrementCount, option);
ElementHelper.clickOnElement(WranglerLocators.applyButton(pluginPropertyDirective));
break;
}
ElementHelper.clickOnElement(WranglerLocators.applyButton);
}

/**
Expand All @@ -267,9 +328,9 @@ public static void selectDirectiveTypeWithFiveOption(String columnName, String d
ElementHelper.clickOnElement(WranglerLocators.locateDirectivesTitle(pluginPropertyDirective));
switch (directive) {
case "SetCounter":
Select select = new Select(WranglerLocators.filterSelect);
Select select = new Select(WranglerLocators.selectDropdownOption(pluginPropertyDirective));
select.selectByVisibleText(option1);
ElementHelper.sendKeysToTextarea(WranglerLocators.filterTextArea, option2);
ElementHelper.sendKeysToTextarea(WranglerLocators.enterTextArea(pluginPropertyDirective), option2);
ElementHelper.sendKeysToTextarea(WranglerLocators.enterCounterName, option4);
ElementHelper.replaceElementValue(WranglerLocators.incrementCount, option3);
break;
Expand All @@ -281,13 +342,13 @@ public static void selectDirectiveTypeWithFiveOption(String columnName, String d
Select selectVar = new Select(WranglerLocators.selectRow);
selectVar.selectByVisibleText(option1);
if (option1.equals("Custom condition")) {
ElementHelper.sendKeysToTextarea(WranglerLocators.filterTextArea, option2);
ElementHelper.sendKeysToTextarea(WranglerLocators.enterTextArea(pluginPropertyDirective), option2);
} else {
ElementHelper.sendKeysToTextarea(WranglerLocators.variableValue, option2);
}
break;
}
ElementHelper.clickOnElement(WranglerLocators.applyButton);
ElementHelper.clickOnElement(WranglerLocators.applyButton(pluginPropertyDirective));
}

/**
Expand All @@ -297,10 +358,11 @@ public static void selectDirectiveTypeWithFiveOption(String columnName, String d
* @throws InterruptedException If interrupted while waiting.
*/
public static void enterDirectiveFromCommandLine(String directive) throws InterruptedException {
WaitHelper.waitForElementToBeClickable(WranglerLocators.directiveCommandLine);
ElementHelper.sendKeys(WranglerLocators.directiveCommandLine, directive);
Actions act = new Actions(SeleniumDriver.getDriver());
act.sendKeys(new CharSequence[]{Keys.ENTER}).perform();
WaitHelper.waitForElementToBeClickable(WranglerLocators.directiveCommandLine);

}

/**
Expand Down
Loading

0 comments on commit 7da3736

Please sign in to comment.