NameSpace Admin page locators actions and step definition addition.#225
NameSpace Admin page locators actions and step definition addition.#225rahuldash171 wants to merge 4 commits intocdapio:developfrom
Conversation
| * keyValuePair as key | ||
| */ | ||
| public static void enterKeyValuePreferences(String preferenceProperty, String keyValuePair) { | ||
| String pluginPropertyDataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute( |
There was a problem hiding this comment.
How is plugin being referenced on namespace admin page?
There was a problem hiding this comment.
Hi Ankit , This plugin is for setting the nameSpace admin preferences which are key-value pairs present inside datacy properties file .
There was a problem hiding this comment.
Plugin in CDAP is used for source/sink/transform/actions: https://cdap.atlassian.net/wiki/spaces/DOCS/pages/477790917/Introduction+to+data+pipelines#Plugins
There was a problem hiding this comment.
Changed the naming to String dataCyAttribute .
ca3dc6d to
86c646f
Compare
…ors were removed which were common in Sys admin and Namespace admin . Sys admin FW PR is merged
| public static WebElement locateKeyProperty(String pluginProperty, int row) { | ||
| String xpath = "//*[@data-cy='" + pluginProperty + "" + row + "']//input[@placeholder='key']"; | ||
| return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); | ||
| } | ||
|
|
||
| public static WebElement locateValueProperty(String pluginProperty, int row) { | ||
| String xpath = "//*[@data-cy='" + pluginProperty + "" + row + "']//input[@placeholder='value']"; | ||
| return SeleniumDriver.getDriver().findElement(By.xpath(xpath)); | ||
| } | ||
|
|
||
| public static WebElement locateAddRowButtonProperty(String pluginProperty, int row) { |
There was a problem hiding this comment.
Same comment applies to this file.
There was a problem hiding this comment.
Ok ankit , I have done the necessary changes . Please have a look in the latest commit . Thanks .
| * {@link ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} with | ||
| * keyValuePair as key | ||
| */ | ||
| public static void enterKeyValuePreferences(String preferenceProperty, String keyValuePair) { |
There was a problem hiding this comment.
The same method already exists here:
Please avoid code duplication.
There was a problem hiding this comment.
Ankit , here the locators are different . The method which is present inside cdfPluginPropertiesActions is pointing to setting runtime arguments for a deployed pipline whereas my method is pointing to setting preferences inside namespace admin . The key and value tabs which are present here does not work with the old locators .
| /** | ||
| * Represents CdfNameSpaceAdminLocators | ||
| */ | ||
| public class CdfNameSpaceAdminLocators { |
There was a problem hiding this comment.
Please get a review on locators class from @GnsP from UI team.
| 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++; | ||
| } |
There was a problem hiding this comment.
The data-cy attributes are specific to tests written using cypress. Prefer using using a custom data- attribute for this action.
| expectedNameSpace); | ||
| } | ||
|
|
||
| public static void verifyElementIsDisplayed() { |
There was a problem hiding this comment.
The method name seems to indicate that this method checks if any given element is displayed, where as it actually checks if the page header is displayed or not. Consider changing the method name to reflect its actual behavior.
| */ | ||
| public class CdfNameSpaceAdminLocators { | ||
|
|
||
| @FindBy(how = How.XPATH, using = "//div[contains(text(),'Namespace Admin')]") |
There was a problem hiding this comment.
Finding elements using text / copy is generally not a good idea, as copy may change based on product requirements and this may result in breaking tests across multiple projects (as this locator is in the e2e framework). Prefer using a data-testid for locating elements.
| @FindBy(how = How.XPATH, using = "//div[contains(text(),'Namespace Admin')]") | ||
| public static WebElement namespaceAdminMenu; | ||
|
|
||
| @FindBy(how = How.XPATH, using = "//*[@data-cy='navbar-hamburger-icon']") |
There was a problem hiding this comment.
prefer data-testid over data-cy.
| return SeleniumDriver.getDriver().findElement(By.xpath(path)); | ||
| } | ||
|
|
||
| public static WebElement locateMenuLink(String menuLink) { |
There was a problem hiding this comment.
prefer data-testid over data-cy
| @FindBy(how = How.XPATH, using = "//span[contains(text(),'Add Connection')]") | ||
| public static WebElement addConnectionTab; | ||
|
|
||
| @FindBy(how = How.XPATH, using = "//span[contains(text(),'Import')]") |
There was a problem hiding this comment.
Locating elements based on text content is not a good idea, as explained in other comments.
| @FindBy(how = How.XPATH, using = "//span[contains(text(),'Import')]") | ||
| public static WebElement importConnectionTab; | ||
|
|
||
| @FindBy(how = How.XPATH, using = "//span[contains(text(),'Create Profile')]") |
There was a problem hiding this comment.
Locating elements based on text content is not a good idea, as explained in other comments.
| @FindBy(how = How.XPATH, using = "//span[contains(text(),'Create Profile')]") | ||
| public static WebElement createProfileInNamespaceAdmin; | ||
|
|
||
| @FindBy(how = How.XPATH, using = "//a[contains(text(),\"Switch to\")]") |
There was a problem hiding this comment.
Locating elements based on text content is not a good idea, as explained in other comments.
| @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.
Locating elements based on css classes is not a good idea, as explained in other comments.
| @FindBy(how = How.XPATH, using = "//div[@class=\"namespace-and-caret\"]") | ||
| public static WebElement namespaceText; | ||
|
|
||
| @FindBy(how = How.XPATH, using = "//*[@data-cy='feature-heading'][//div[contains(text(),'Namespace')]]") |
There was a problem hiding this comment.
Locating elements based on text content is not a good idea, as explained in other comments.
Namespace admin page FW changes for new locators , actions and step defs .