-
Notifications
You must be signed in to change notification settings - Fork 25
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. #225
base: develop
Are you sure you want to change the base?
Conversation
* keyValuePair as key | ||
*/ | ||
public static void enterKeyValuePreferences(String preferenceProperty, String keyValuePair) { | ||
String pluginPropertyDataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute( |
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.
How is plugin being referenced on namespace admin page?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment applies to this file.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same method already exists here:
cdap-e2e-tests/src/main/java/io/cdap/e2e/pages/actions/CdfPluginPropertiesActions.java
Line 946 in 44f61d8
public static void enterKeyValuePairsForProperty(String pluginProperty, String jsonKeyValuePairs) { |
Please avoid code duplication.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 .