All waitClickable calls were being followed by a click.
This will remove the need for the click call.
Signed-off-by: Tiago Melo <tmelo@suse.com>
images.getFirstTableCellWithText(newImageName),
'Timed out waiting for image to restore'
);
- await images.waitClickable(
- images.getFirstTableCellWithText(newImageName),
- 'Timed out waiting for image to be clickable'
- );
await images.moveToTrash(newImageName);
await images.purgeTrash(newImageName, poolName);
});
await element(by.cssContainingText('button', 'Edit RBD')).click();
await this.navigateTo();
- await this.waitClickable(this.getFirstTableCellWithText(newName));
- // click edit button and wait to make sure new owner is present in table
- await this.getFirstTableCellWithText(newName).click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(newName));
await expect(
element
.all(by.css('.table.table-striped.table-bordered'))
await this.navigateTo();
// wait for image to be created
await this.waitTextNotPresent($$('.datatable-body').first(), '(Creating...)');
- await this.waitClickable(this.getFirstTableCellWithText(name));
- await this.getFirstTableCellWithText(name).click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
// click on the drop down and selects the move to trash option
await $$('.table-actions button.dropdown-toggle')
.first()
await element(by.cssContainingText('button', 'Move Image')).click();
await this.navigateTo();
// Clicks trash tab
- await this.waitClickable(element(by.cssContainingText('.nav-link', 'Trash')));
- await element(by.cssContainingText('.nav-link', 'Trash')).click();
+ await this.waitClickableAndClick(element(by.cssContainingText('.nav-link', 'Trash')));
await this.waitPresence(this.getFirstTableCellWithText(name));
}
// clicks on trash tab
await element(by.cssContainingText('.nav-link', 'Trash')).click();
// wait for table to load
- await this.waitClickable(this.getFirstTableCellWithText(name));
- await this.getFirstTableCellWithText(name).click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
await element(by.cssContainingText('button', 'Restore')).click();
// wait for pop-up to be visible (checks for title of pop-up)
await this.waitVisibility(element(by.id('name')));
await $(getPoolName).click();
await expect(element(by.id('poolName')).getAttribute('class')).toContain('ng-valid'); // check if pool is selected
}
- await this.waitClickable(element(by.id('purgeFormButton')));
- await element(by.id('purgeFormButton')).click();
+ await this.waitClickableAndClick(element(by.id('purgeFormButton')));
// Wait for image to delete and check it is not present
await this.waitStaleness(
this.getFirstTableCellWithText(name),
@PageHelper.restrictTo(pages.index)
async editMirror(name, option) {
// Clicks the pool in the table
- await this.waitClickable(this.getFirstTableCellWithText(name));
- await this.getFirstTableCellWithText(name).click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
// Clicks the Edit Mode button
const editModeButton = element(by.cssContainingText('button', 'Edit Mode'));
- await this.waitClickable(editModeButton);
- await editModeButton.click();
+ await this.waitClickableAndClick(editModeButton);
// Clicks the drop down in the edit pop-up, then clicks the Update button
await this.waitVisibility($('.modal-content'));
await element(by.id('mirrorMode')).click(); // Mode select box
await $('input.form-control.ng-valid').sendKeys(name);
// Selects config that we want to clear
- await this.waitClickable(this.getFirstTableCellWithText(name)); // waits for config to be clickable
- await this.getFirstTableCellWithText(name).click(); // click on the config to edit
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // waits for config to be clickable and click
await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
for (const i of valList) {
await $('input.form-control.ng-valid').clear();
await $('input.form-control.ng-valid').sendKeys(name);
- await this.waitClickable(this.getFirstTableCellWithText(name));
- await this.getFirstTableCellWithText(name).click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
// Clicks desired config
await this.waitVisibility(
$('.table.table-striped.table-bordered'), // Checks for visibility of details tab
await $('input.form-control.ng-valid').sendKeys(name);
// Selects config that we want to edit
- await this.waitClickable(this.getFirstTableCellWithText(name)); // waits for config to be clickable
- await this.getFirstTableCellWithText(name).click(); // click on the config to edit
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // waits for config to be clickable and click
await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
await this.waitTextToBePresent(this.getBreadcrumb(), 'Edit');
// Doesn't check/uncheck boxes because it is not reflected in the details table.
// DOES NOT WORK FOR ALL MGR MODULES, for example, Device health
await this.navigateTo();
- await this.waitClickable(this.getFirstTableCellWithText(name));
- await this.getFirstTableCellWithText(name).click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
await element(by.cssContainingText('button', 'Edit')).click();
for (const entry of tuple) {
// Clear mgr module of all edits made to it
await this.navigateTo();
- await this.waitClickable(this.getFirstTableCellWithText(name));
- await this.getFirstTableCellWithText(name).click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
await element(by.cssContainingText('button', 'Edit')).click();
// Clears the editable fields
[warn, 'warn_threshold']
];
- await this.waitClickable(this.getFirstTableCellWithText('devicehealth'));
- await this.getFirstTableCellWithText('devicehealth').click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText('devicehealth'));
await element(by.cssContainingText('button', 'Edit')).click();
for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) {
if (devHealthTuple[0] !== undefined) {
// (on my local run of ceph-dev, this is subject to change i would assume). I'd imagine there is a
// better way of doing this.
await this.navigateTo();
- await this.waitClickable(this.getFirstTableCellWithText('devicehealth')); // checks ansible
- await this.getFirstTableCellWithText('devicehealth').click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText('devicehealth')); // checks ansible
await element(by.cssContainingText('button', 'Edit')).click();
await this.clearInput(element(by.id('mark_out_threshold')));
await element(by.id('mark_out_threshold')).sendKeys('2419200');
await element(by.id('warn_threshold')).sendKeys('7257600');
// Checks that clearing represents in details tab of ansible
- await this.waitClickable(element(by.cssContainingText('button', 'Update')));
- await element(by.cssContainingText('button', 'Update')).click();
+ await this.waitClickableAndClick(element(by.cssContainingText('button', 'Update')));
await this.navigateTo();
await this.waitVisibility(this.getFirstTableCellWithText('devicehealth'));
await this.getFirstTableCellWithText('devicehealth').click();
);
}
- await this.waitClickable(label);
- return label.click();
+ return this.waitClickableAndClick(label);
}
/**
return browser.wait(EC.stalenessOf(elem), TIMEOUT, message);
}
- async waitClickable(elem: ElementFinder, message?: string) {
- return browser.wait(EC.elementToBeClickable(elem), TIMEOUT, message);
+ /**
+ * This method will wait for the element to be clickable and then click it.
+ */
+ async waitClickableAndClick(elem: ElementFinder, message?: string) {
+ await browser.wait(EC.elementToBeClickable(elem), TIMEOUT, message);
+ return elem.click();
}
async waitVisibility(elem: ElementFinder, message?: string) {
*/
async delete(name: string): Promise<any> {
// Selects row
- await this.waitClickable(this.getFirstTableCellWithText(name));
- await this.getFirstTableCellWithText(name).click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
// Clicks on table Delete button
await $$('.table-actions button.dropdown-toggle')
await element(by.cssContainingText('select[name=owner] option', new_owner)).click(); // select the new user
await element(by.cssContainingText('button', 'Edit Bucket')).click();
- // wait to be back on buckets page with table visible
- await this.waitClickable(
+ // wait to be back on buckets page with table visible and click
+ await this.waitClickableAndClick(
this.getFirstTableCellWithText(name),
'Could not return to buckets page and load table after editing bucket'
);
- // click on edited bucket and check its details table for edited owner field
- const promise = await this.getFirstTableCellWithText(name).click();
+ // check its details table for edited owner field
const element_details_table = element
.all(by.css('.table.table-striped.table-bordered'))
.first();
- await expect(element_details_table.getText()).toMatch(new_owner);
- return promise;
+ return expect(element_details_table.getText()).toMatch(new_owner);
}
async testInvalidCreate() {
async testInvalidEdit(name) {
await this.navigateTo();
- await this.waitClickable(
+ await this.waitClickableAndClick(
this.getFirstTableCellWithText(name),
'Failed waiting for bucket to be present in table'
); // wait for table to load
- await this.getFirstTableCellWithText(name).click(); // click on the bucket you want to edit in the table
await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page
await this.waitTextToBePresent(this.getBreadcrumb(), 'Edit');
// Chooses 'Select a user' rather than a valid owner on Edit Bucket page
// and checks if it's an invalid input
const ownerDropDown = element(by.id('owner'));
- await this.waitClickable(ownerDropDown);
- await ownerDropDown.click(); // Clicks the Owner drop down on the Create Bucket page
+ await this.waitClickableAndClick(ownerDropDown);
// select the first option, which is invalid because it is a placeholder
await element(by.cssContainingText('select[name=owner] option', 'Select a user')).click();
async edit(name, new_fullname, new_email, new_maxbuckets) {
await this.navigateTo();
- await this.waitClickable(this.getFirstTableCellWithText(name)); // wait for table to load
- await this.getFirstTableCellWithText(name).click(); // click on the bucket you want to edit in the table
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // wait for table to load and click
await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page
await this.waitTextToBePresent(this.getBreadcrumb(), 'Edit');
const editbutton = element(by.cssContainingText('button', 'Edit User'));
await editbutton.click();
- await this.waitClickable(this.getFirstTableCellWithText(name));
// Click the user and check its details table for updated content
- await this.getFirstTableCellWithText(name).click();
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
await expect($('.active.tab-pane').getText()).toMatch(new_fullname); // check full name was changed
await expect($('.active.tab-pane').getText()).toMatch(new_email); // check email was changed
await expect($('.active.tab-pane').getText()).toMatch(new_maxbuckets); // check max buckets was changed
await this.navigateTo();
- await this.waitClickable(this.getFirstTableCellWithText(uname)); // wait for table to load
- await this.getFirstTableCellWithText(uname).click(); // click on the bucket you want to edit in the table
+ // wait for table to load and click on the bucket you want to edit in the table
+ await this.waitClickableAndClick(this.getFirstTableCellWithText(uname));
await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page
await this.waitTextToBePresent(this.getBreadcrumb(), 'Edit');