- remove some awaits

- add try catch
- small refactoring
This commit is contained in:
Adina Parpalita
2019-10-17 17:31:29 +03:00
parent 9fd47d3186
commit 227e05e3f9
39 changed files with 1243 additions and 905 deletions

View File

@@ -67,73 +67,73 @@ export class CommentsTab extends Component {
}
async getCommentsTabHeaderText() {
return await this.commentsHeader.getText();
return this.commentsHeader.getText();
}
async isCommentTextAreaDisplayed() {
return await browser.isElementPresent(this.commentTextarea);
return browser.isElementPresent(this.commentTextarea);
}
async isAddCommentButtonEnabled() {
const present = await browser.isElementPresent(this.addCommentButton);
if (present) {
return await this.addCommentButton.isEnabled();
return this.addCommentButton.isEnabled();
}
return false;
}
async getCommentListItem() {
return await browser.wait(until.elementLocated(this.commentListItem), BROWSER_WAIT_TIMEOUT / 2);
return browser.wait(until.elementLocated(this.commentListItem), BROWSER_WAIT_TIMEOUT / 2);
}
async getCommentById(commentId?: string) {
if (commentId) {
return await browser.wait(until.elementLocated(by.id(`${CommentsTab.selectors.commentById}${commentId}`)), BROWSER_WAIT_TIMEOUT / 2);
return browser.wait(until.elementLocated(by.id(`${CommentsTab.selectors.commentById}${commentId}`)), BROWSER_WAIT_TIMEOUT / 2);
}
return await this.getCommentListItem();
return this.getCommentListItem();
}
async isCommentDisplayed(commentId?: string) {
return await browser.isElementPresent(await this.getCommentById(commentId));
return browser.isElementPresent(await this.getCommentById(commentId));
}
async isCommentUserAvatarDisplayed(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
return await browser.isElementPresent(commentElement.findElement(this.commentUserAvatar));
return browser.isElementPresent(commentElement.findElement(this.commentUserAvatar));
}
async getCommentText(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
const message = await commentElement.findElement(this.commentText);
return await message.getText();
return message.getText();
}
async getCommentUserName(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
const user = await commentElement.findElement(this.commentUser);
return await user.getText();
return user.getText();
}
async getCommentTime(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
const time = await commentElement.findElement(this.commentTime);
return await time.getText();
return time.getText();
}
async getNthCommentId(index: number) {
return await this.commentsList.get(index - 1).getAttribute('id');
return this.commentsList.get(index - 1).getAttribute('id');
}
async typeComment(text: string) {
return await this.commentTextarea.sendKeys(text);
await this.commentTextarea.sendKeys(text);
}
async clickAddButton() {
return await this.addCommentButton.click();
await this.addCommentButton.click();
}
async getCommentTextFromTextArea() {
return await this.commentTextarea.getAttribute('value');
return this.commentTextarea.getAttribute('value');
}
}

View File

@@ -58,11 +58,11 @@ export class ContentMetadata extends Component {
}
async isPropertiesListExpanded() {
return await browser.isElementPresent(this.expandedPanel);
return browser.isElementPresent(this.expandedPanel);
}
async waitForImagePropertiesPanelToExpand() {
return await browser.wait(EC.visibilityOf(this.expandedImagePropertiesPanel), BROWSER_WAIT_TIMEOUT);
await browser.wait(EC.visibilityOf(this.expandedImagePropertiesPanel), BROWSER_WAIT_TIMEOUT);
}
async getVisiblePropertiesLabels() {
@@ -98,19 +98,19 @@ export class ContentMetadata extends Component {
}
async isLessInfoButtonDisplayed() {
return await browser.isElementPresent(this.lessInfoButton);
return browser.isElementPresent(this.lessInfoButton);
}
async isMoreInfoButtonDisplayed() {
return await browser.isElementPresent(this.moreInfoButton);
return browser.isElementPresent(this.moreInfoButton);
}
async clickLessInformationButton() {
return await this.lessInfoButton.click();
await this.lessInfoButton.click();
}
async clickMoreInformationButton() {
return await this.moreInfoButton.click();
await this.moreInfoButton.click();
}
async isImagePropertiesPanelDisplayed() {
@@ -118,7 +118,7 @@ export class ContentMetadata extends Component {
}
async clickImagePropertiesPanel() {
return await this.imagePropertiesPanel.click();
await this.imagePropertiesPanel.click();
}
}

View File

@@ -72,7 +72,7 @@ export class LibraryMetadata extends Component {
}
async isFieldDisplayed(fieldName: string) {
return await browser.isElementPresent(this.getFieldByName(fieldName));
return browser.isElementPresent(this.getFieldByName(fieldName));
}
async isInputEnabled(fieldName: string) {
@@ -80,13 +80,13 @@ export class LibraryMetadata extends Component {
}
async getValueOfField(fieldName: string) {
return await this.getFieldByName(fieldName).getText();
return this.getFieldByName(fieldName).getText();
}
async enterTextInInput(fieldName: string, text: string) {
const input = this.getFieldByName(fieldName);
await input.clear();
return await input.sendKeys(text);
await input.sendKeys(text);
}
@@ -99,11 +99,11 @@ export class LibraryMetadata extends Component {
}
async isButtonEnabled(button: string) {
return await this.getButton(button).isEnabled();
return this.getButton(button).isEnabled();
}
async clickButton(button: string) {
return await this.getButton(button).click();
await this.getButton(button).click();
}
async waitForVisibilityDropDownToOpen() {
@@ -115,68 +115,68 @@ export class LibraryMetadata extends Component {
}
async isMessageDisplayed() {
return await browser.isElementPresent(this.hint);
return browser.isElementPresent(this.hint);
}
async getMessage() {
return await this.hint.getText();
return this.hint.getText();
}
async isErrorDisplayed() {
return await browser.isElementPresent(this.error);
return browser.isElementPresent(this.error);
}
async getError() {
return await this.error.getText();
return this.error.getText();
}
async isNameDisplayed() {
return await this.isFieldDisplayed('Name');
return this.isFieldDisplayed('Name');
}
async isNameEnabled() {
return await this.isInputEnabled('Name');
return this.isInputEnabled('Name');
}
async getName() {
return await this.getValueOfField('Name');
return this.getValueOfField('Name');
}
async enterName(name: string) {
return await this.enterTextInInput('Name', name);
await this.enterTextInInput('Name', name);
}
async isDescriptionDisplayed() {
return await this.isFieldDisplayed('Description');
return this.isFieldDisplayed('Description');
}
async isDescriptionEnabled() {
return await this.isInputEnabled('Description');
return this.isInputEnabled('Description');
}
async getDescription() {
return await this.getValueOfField('Description');
return this.getValueOfField('Description');
}
async enterDescription(desc: string) {
return await this.enterTextInInput('Description', desc);
await this.enterTextInInput('Description', desc);
}
async isVisibilityEnabled() {
const wrapper = this.getLabelWrapper('Visibility');
const field = wrapper.element(by.xpath('..')).element(by.css(LibraryMetadata.selectors.dropDown));
return await field.isEnabled();
return field.isEnabled();
}
async isVisibilityDisplayed() {
return await this.isFieldDisplayed('Visibility');
return this.isFieldDisplayed('Visibility');
}
async getVisibility() {
return await this.getValueOfField('Visibility');
return this.getValueOfField('Visibility');
}
async setVisibility(visibility: string) {
@@ -200,54 +200,54 @@ export class LibraryMetadata extends Component {
async isLibraryIdDisplayed() {
return await this.isFieldDisplayed('Library ID');
return this.isFieldDisplayed('Library ID');
}
async isLibraryIdEnabled() {
return await this.isInputEnabled('Library ID');
return this.isInputEnabled('Library ID');
}
async getLibraryId() {
return await this.getValueOfField('Library ID');
return this.getValueOfField('Library ID');
}
async isEditLibraryPropertiesEnabled() {
return await this.isButtonEnabled('Edit');
return this.isButtonEnabled('Edit');
}
async isEditLibraryPropertiesDisplayed() {
return await this.isButtonDisplayed('Edit');
return this.isButtonDisplayed('Edit');
}
async clickEditLibraryProperties() {
return await this.clickButton('Edit');
await this.clickButton('Edit');
}
async isUpdateEnabled() {
return await this.isButtonEnabled('Update');
return this.isButtonEnabled('Update');
}
async isUpdateDisplayed() {
return await this.isButtonDisplayed('Update');
return this.isButtonDisplayed('Update');
}
async clickUpdate() {
return await this.clickButton('Update');
await this.clickButton('Update');
}
async isCancelEnabled() {
return await this.isButtonEnabled('Cancel');
return this.isButtonEnabled('Cancel');
}
async isCancelDisplayed() {
return await this.isButtonDisplayed('Cancel');
return this.isButtonDisplayed('Cancel');
}
async clickCancel() {
return await this.clickButton('Cancel');
await this.clickButton('Cancel');
}
}

View File

@@ -69,11 +69,11 @@ export class InfoDrawer extends Component {
}
async waitForInfoDrawerToOpen() {
return await browser.wait(EC.presenceOf(this.header), BROWSER_WAIT_TIMEOUT);
await browser.wait(EC.presenceOf(this.header), BROWSER_WAIT_TIMEOUT);
}
async isOpen() {
return await browser.isElementPresent(this.header);
return browser.isElementPresent(this.header);
}
async isEmpty() {
@@ -85,27 +85,27 @@ export class InfoDrawer extends Component {
}
async getTabsCount() {
return await this.component.all(by.css(InfoDrawer.selectors.tabLabel)).count();
return this.component.all(by.css(InfoDrawer.selectors.tabLabel)).count();
}
async isTabPresent(title: string) {
return await this.getTabByTitle(title).isPresent();
return this.getTabByTitle(title).isPresent();
}
async isTabDisplayed(title: string): Promise<boolean> {
if (await browser.isElementPresent(this.getTabByTitle(title))) {
return await this.getTabByTitle(title).isDisplayed();
return this.getTabByTitle(title).isDisplayed();
}
return false;
}
async getTabTitle(index: number) {
return await this.tabLabelsList.get(index - 1).getAttribute('innerText');
return this.tabLabelsList.get(index - 1).getAttribute('innerText');
}
async getActiveTabTitle() {
return await this.tabActiveLabel.getText();
return this.tabActiveLabel.getText();
}
async clickTab(title: string) {
@@ -113,19 +113,19 @@ export class InfoDrawer extends Component {
}
async getComponentIdOfTab() {
return await this.tabActiveContent.getAttribute('data-automation-id');
return this.tabActiveContent.getAttribute('data-automation-id');
}
async getHeaderTitle() {
return await this.headerTitle.getText();
return this.headerTitle.getText();
}
async isAboutTabDisplayed() {
return await this.isTabDisplayed('About');
return this.isTabDisplayed('About');
}
async isPropertiesTabDisplayed() {
return await this.isTabDisplayed('Properties');
return this.isTabDisplayed('Properties');
}
async isPropertiesTabActive() {
@@ -133,7 +133,7 @@ export class InfoDrawer extends Component {
}
async isCommentsTabDisplayed() {
return await this.isTabDisplayed('Comments');
return this.isTabDisplayed('Comments');
}
async clickCommentsTab() {
@@ -145,8 +145,7 @@ export class InfoDrawer extends Component {
browser.wait(EC.invisibilityOf(this.propertiesTab.component), BROWSER_WAIT_TIMEOUT)
]);
} catch (error) {
console.error('--- catch error on clickCommentsTab ---');
throw error;
console.error('--- info-drawer clickCommentsTab catch error: ', error);
}
}