forked from cdapio/cdap-e2e-tests
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NameSpace Admin page locators actions and step definition addition #16
Open
rahuldash171
wants to merge
4
commits into
develop
Choose a base branch
from
cdap_e2e_NameSpaceAdmin_FW
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e15edd7
NameSpace Admin page locators actions and step definition addition.
rahuldash171 86c646f
Addressed review comments
rahuldash171 11d67de
Addressed review comments and most of the repeated actions/step/locat…
rahuldash171 c5b3b10
Renamed the texts pluginProperty to correct naming .
rahuldash171 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
src/main/java/io/cdap/e2e/pages/actions/CdfNameSpaceAdminActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright © 2023 Cask Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package io.cdap.e2e.pages.actions; | ||
|
||
import io.cdap.e2e.pages.locators.CdfNameSpaceAdminLocators; | ||
import io.cdap.e2e.pages.locators.CdfSysAdminLocators; | ||
import io.cdap.e2e.utils.AssertionHelper; | ||
import io.cdap.e2e.utils.ConstantsUtil; | ||
import io.cdap.e2e.utils.ElementHelper; | ||
import io.cdap.e2e.utils.JsonUtils; | ||
import io.cdap.e2e.utils.PluginPropertyUtils; | ||
import io.cdap.e2e.utils.SeleniumHelper; | ||
import io.cdap.e2e.utils.WaitHelper; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import java.util.Map; | ||
|
||
/** | ||
* Represents CdfNameSpaceAdminActions | ||
*/ | ||
public class CdfNameSpaceAdminActions { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(CdfNameSpaceAdminActions.class); | ||
public static CdfNameSpaceAdminLocators cdfNameSpaceAdminLocators; | ||
|
||
static { | ||
cdfNameSpaceAdminLocators = SeleniumHelper.getPropertiesLocators( | ||
CdfNameSpaceAdminLocators.class); | ||
} | ||
|
||
public static void clickOnNameSpaceAdminTabs(String tabName, String nameSpaceName) { | ||
ElementHelper.clickOnElement( | ||
CdfNameSpaceAdminLocators.nameSpaceModules(tabName, nameSpaceName)); | ||
} | ||
|
||
public static void openNamespaceAdminPage() { | ||
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.namespaceAdminMenu); | ||
} | ||
|
||
public static void clickOnHamburgerMenu() { | ||
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.hamburgerMenu); | ||
} | ||
|
||
public static void switchToNameSpace(String nameSpaceName) { | ||
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.switchNameSpace(nameSpaceName)); | ||
} | ||
|
||
public static void createProfileForNamespace(String nameSpaceName) { | ||
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.createProfile(nameSpaceName)); | ||
} | ||
|
||
public static void openNamespaceDropdown() { | ||
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.namespaceDropdown); | ||
} | ||
|
||
public static void addNamespaceFromHamburgerMenu() { | ||
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.addNamespace); | ||
} | ||
|
||
/** | ||
* Enter KeyValue Pairs For Preference Property | ||
* | ||
* @param preferenceProperty @data-cy attribute value of preference Property. If | ||
* preferenceProperty is present in | ||
* {@link ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE} then its data-cy | ||
* is fetched from it else preferenceProperty is used as it is. | ||
* @param keyValuePair Actual json KeyValue Pairs string is fetched from | ||
* {@link ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} with | ||
* keyValuePair as key | ||
*/ | ||
public static void enterKeyValuePreferences(String preferenceProperty, String keyValuePair) { | ||
String dataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute( | ||
preferenceProperty); | ||
if (dataCyAttribute == null) { | ||
dataCyAttribute = preferenceProperty; | ||
} | ||
Map<String, String> properties = | ||
JsonUtils.convertKeyValueJsonArrayToMap(PluginPropertyUtils.pluginProp(keyValuePair)); | ||
int index = 0; | ||
for (Map.Entry<String, String> entry : properties.entrySet()) { | ||
if (index != 0) { | ||
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.locateAddRowButtonProperty( | ||
dataCyAttribute, index - 1)); | ||
} | ||
ElementHelper.sendKeys(CdfNameSpaceAdminLocators.locateKeyProperty( | ||
dataCyAttribute, index), entry.getKey()); | ||
ElementHelper.sendKeys(CdfNameSpaceAdminLocators.locateValueProperty( | ||
dataCyAttribute, index), entry.getValue()); | ||
index++; | ||
} | ||
} | ||
|
||
public static void switchToNewNameSpace() { | ||
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.switchToNameSpaceButton); | ||
} | ||
|
||
public static void verifySwitchToNewNamespace(String value) { | ||
String expectedNameSpace = PluginPropertyUtils.pluginProp(value); | ||
AssertionHelper.verifyElementContainsText(CdfNameSpaceAdminLocators.namespaceText, | ||
expectedNameSpace); | ||
} | ||
|
||
public static void verifyElementIsDisplayed() { | ||
ElementHelper.isElementDisplayed(CdfNameSpaceAdminLocators.pageHeaderNameSpaceAdmin); | ||
} | ||
} |
160 changes: 160 additions & 0 deletions
160
src/main/java/io/cdap/e2e/pages/locators/CdfNameSpaceAdminLocators.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/* | ||
* Copyright © 2023 Cask Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package io.cdap.e2e.pages.locators; | ||
|
||
import io.cdap.e2e.utils.SeleniumDriver; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
import org.openqa.selenium.support.How; | ||
|
||
/** | ||
* Represents CdfNameSpaceAdminLocators | ||
*/ | ||
public class CdfNameSpaceAdminLocators { | ||
|
||
@FindBy(how = How.XPATH, using = "//div[contains(text(),'Namespace Admin')]") | ||
public static WebElement namespaceAdminMenu; | ||
|
||
@FindBy(how = How.XPATH, using = "//*[@data-cy='navbar-hamburger-icon']") | ||
public static WebElement hamburgerMenu; | ||
|
||
public static WebElement nameSpaceModules(String module, String nameSpace) { | ||
String path = "//*[@href=\"/cdap/ns/" + nameSpace + "/details/" + module + "\"]"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(path)); | ||
} | ||
|
||
public static WebElement createProfile(String nameSpace) { | ||
String path = "//*[@href=\"/cdap/ns/" + nameSpace + "/profiles/create\"]"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(path)); | ||
} | ||
|
||
public static WebElement switchNameSpace(String nameSpace) { | ||
String path = "//*[@href=\"/cdap/ns/'" + nameSpace + "'\"]"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(path)); | ||
} | ||
|
||
public static WebElement locateMenuLink(String menuLink) { | ||
String xpath = "//*[@data-cy='navbar-" + menuLink + "-link']"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); | ||
} | ||
|
||
public static WebElement locateKeyProperty(String keyProperty, int row) { | ||
String xpath = "//*[@data-cy='" + keyProperty + "" + row + "']//input[@placeholder='key']"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); | ||
} | ||
|
||
public static WebElement locateValueProperty(String valueProperty, int row) { | ||
String xpath = "//*[@data-cy='" + valueProperty + "" + row + "']//input[@placeholder='value']"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); | ||
} | ||
|
||
public static WebElement locateAddRowButtonProperty(String addRowProperty, int row) { | ||
String xpath = | ||
"//*[@data-cy='" + addRowProperty + "" + row + "']//span" | ||
+ "//button[@type='submit' and @class='btn add-row-btn btn-link']"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); | ||
} | ||
|
||
@FindBy(how = How.XPATH, using = "//*[@class='namespace-dropdown']") | ||
public static WebElement namespaceDropdown; | ||
|
||
@FindBy(how = How.XPATH, using = "//div[contains(text(),'Add Namespace')]") | ||
public static WebElement addNamespace; | ||
|
||
@FindBy(how = How.XPATH, using = "//button[@data-cy='wizard-next-btn']") | ||
public static WebElement clickOnNextButton; | ||
|
||
@FindBy(how = How.XPATH, using = "//button[@data-cy='wizard-finish-btn']") | ||
public static WebElement clickOnFinishButton; | ||
|
||
public static WebElement locateKeyProperty(int row) { | ||
String xpath = "//*[@data-cy= 'key-value-pair-" + row + "']//input[@placeholder='key']"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); | ||
} | ||
|
||
public static WebElement locateValueProperty(int row) { | ||
String xpath = "//*[@data-cy= 'key-value-pair-" + row + "']//input[@placeholder='value']"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); | ||
} | ||
|
||
public static WebElement locateAddRowButtonProperty(int row) { | ||
String xpath = "//*[@data-cy= 'key-value-pair-" + row + "']//span//button[@type='submit' and " + | ||
"@class='btn add-row-btn btn-link']"; | ||
return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); | ||
} | ||
|
||
public static WebElement locateProvisionerInList(String provisionerName) { | ||
return SeleniumDriver.getDriver() | ||
.findElement(By.xpath("//div[@data-cy='" + provisionerName + "']")); | ||
} | ||
|
||
public static WebElement locateButtonType(String buttonType) { | ||
return SeleniumDriver.getDriver() | ||
.findElement(By.xpath("//button[@data-cy='" + buttonType + "']")); | ||
} | ||
|
||
public static By profilePropertiesPage() { | ||
return By.xpath("//h5[contains(text(), 'Create a profile')]"); | ||
} | ||
|
||
public static By locateProfileTitle(String profileName) { | ||
return By.xpath("//div[@title='" + profileName + "']"); | ||
} | ||
|
||
@FindBy(how = How.XPATH, using = "//a[contains(text(),\"Switch to\")]") | ||
public static WebElement switchToCreatedNamespace; | ||
|
||
@FindBy(how = How.XPATH, using = "//a[contains(text(),'Go to homepage')]") | ||
public static WebElement goToHomepage; | ||
|
||
@FindBy(how = How.XPATH, using = "//*[@data-cy='wizard-result-icon-close-btn']") | ||
public static WebElement closeAddNameSpaceWindow; | ||
|
||
@FindBy(how = How.XPATH, using = "//span[@id='setpreferences-fd']") | ||
public static WebElement setPreferencesfromMainMenu; | ||
|
||
@FindBy(how = How.XPATH, using = "//span[contains(text(),'Upload Driver')]") | ||
public static WebElement uploadDriverTab; | ||
|
||
@FindBy(how = How.XPATH, using = "//*[contains(@class,'close')]") | ||
public static WebElement closeUploadDriverWindow; | ||
|
||
@FindBy(how = How.XPATH, using = "//span[contains(text(),'Link Repository')]") | ||
public static WebElement linkRepositoryTab; | ||
|
||
@FindBy(how = How.XPATH, using = "//button[@class=\"MuiButtonBase-root MuiIconButton-root\"]") | ||
public static WebElement closeExternalPage; | ||
|
||
@FindBy(how = How.XPATH, using = "//span[contains(text(),'Add Connection')]") | ||
public static WebElement addConnectionTab; | ||
|
||
@FindBy(how = How.XPATH, using = "//span[contains(text(),'Import')]") | ||
public static WebElement importConnectionTab; | ||
|
||
@FindBy(how = How.XPATH, using = "//span[contains(text(),'Create Profile')]") | ||
public static WebElement createProfileInNamespaceAdmin; | ||
|
||
@FindBy(how = How.XPATH, using = "//a[contains(text(),\"Switch to\")]") | ||
public static WebElement switchToNameSpaceButton; | ||
|
||
@FindBy(how = How.XPATH, using = "//div[@class=\"namespace-and-caret\"]") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we can find an Id for these locators we should use them. As class names can be changed in UI mostly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
public static WebElement namespaceText; | ||
|
||
@FindBy(how = How.XPATH, using = "//*[@data-cy='feature-heading'][//div[contains(text(),'Namespace')]]") | ||
public static WebElement pageHeaderNameSpaceAdmin; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright © 2023 Cask Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package stepsdesign; | ||
|
||
import io.cdap.e2e.pages.actions.CdfNameSpaceAdminActions; | ||
import io.cdap.e2e.pages.actions.CdfPluginPropertiesActions; | ||
import io.cdap.e2e.utils.CdfHelper; | ||
import io.cucumber.java.en.Then; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Represents CdfNameSpaceAdminSteps | ||
*/ | ||
public class NameSpaceadminSteps implements CdfHelper { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(NameSpaceadminSteps.class); | ||
|
||
@Then("Click on the Hamburger bar on the left panel") | ||
public static void clickOnTheHamburgerIcon() { | ||
CdfNameSpaceAdminActions.clickOnHamburgerMenu(); | ||
} | ||
|
||
@Then("Click on NameSpace Admin link from the menu") | ||
public void openNameSpaceAdminPage() { | ||
CdfNameSpaceAdminActions.openNamespaceAdminPage(); | ||
} | ||
|
||
@Then("Click on create profile button for {string} Namespace") | ||
public void createProfileinsideNamespaceAdmin(String nameSpace) { | ||
CdfNameSpaceAdminActions.createProfileForNamespace(nameSpace); | ||
} | ||
|
||
@Then("Go to {string} tab from Configuration page for {string} Namespace") | ||
public void openNameSpaceAdminPageTabs(String tabName, String nameSpace) { | ||
CdfNameSpaceAdminActions.clickOnNameSpaceAdminTabs(tabName, nameSpace); | ||
} | ||
|
||
@Then("Click on Namespace dropdown button") | ||
public void openNameSpaceDropdown() { | ||
CdfNameSpaceAdminActions.openNamespaceDropdown(); | ||
} | ||
|
||
@Then("Click on the Add Namespace tab") | ||
public void addNamespaceFromHamburgerMenu() { | ||
CdfNameSpaceAdminActions.addNamespaceFromHamburgerMenu(); | ||
} | ||
|
||
@Then("Set namespace preferences with key: {string} and value: {string}") | ||
public void setNamespacePreferencesWithKeyAndValue(String keyProperty, String keyValuePairs) { | ||
CdfNameSpaceAdminActions.enterKeyValuePreferences(keyProperty, keyValuePairs); | ||
} | ||
|
||
@Then("Switch to the newly created Namespace") | ||
public void switchToNewNameSpace() { | ||
CdfNameSpaceAdminActions.switchToNewNameSpace(); | ||
} | ||
|
||
@Then("Verify the namespace is switched to {string} successfully") | ||
public void verifyNameSpaceSwitch(String newNameSpaceName) { | ||
CdfNameSpaceAdminActions.verifySwitchToNewNamespace(newNameSpaceName); | ||
} | ||
|
||
@Then("Add connection type as {string} and provide a {string}") | ||
public void addConnectionInNameSpaceAdmin(String connectionType, String connectionName) { | ||
CdfPluginPropertiesActions.clickPluginPropertyElement(connectionType); | ||
CdfPluginPropertiesActions.enterValueInInputProperty("name", connectionName); | ||
CdfPluginPropertiesActions.replaceValueInInputProperty("projectId", "projectId"); | ||
} | ||
|
||
@Then("Verify if user successfully navigated to namespace admin page") | ||
public void verifyThatNamespacePageIsSuccessfullyOpened() { | ||
CdfNameSpaceAdminActions.verifyElementIsDisplayed(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the camel casing in above 2 method names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fix the Hamburger spelling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed the spelling , changed the method name to addNamespaceFromHamburgerMenu()