search button workaround

This commit is contained in:
Denys Vuika
2023-02-25 17:12:50 -05:00
parent 2c936e663d
commit 67a3f9626b

View File

@@ -29,7 +29,10 @@ import { waitForPresence, waitElement } from '../../utilities/utils';
import { BrowserActions, BrowserVisibility, TestElement } from '@alfresco/adf-testing';
export class SearchInput extends Component {
searchButton = this.component.element(by.css('.app-search-button'));
get searchButton() {
return browser.element(by.css('.app-search-button'));
}
searchContainer = browser.element(by.css('.app-search-container'));
searchControl = browser.element(by.css('.app-search-control'));
@@ -59,6 +62,11 @@ export class SearchInput extends Component {
async clickSearchButton() {
await BrowserActions.click(this.searchButton);
// TODO: Workaround for new Layout having 2 buttons
await waitForPresence(this.searchButton);
await BrowserActions.click(this.searchButton);
await this.waitForSearchControl();
}
@@ -158,22 +166,22 @@ export class SearchInput extends Component {
await BrowserActions.click(this.searchButton);
}
async searchByURL(text: string){
async searchByURL(text: string) {
const query = Buffer.from(text, 'utf-8').toString();
await BrowserActions.getUrl(`#/search;q=${query}`);
}
async searchUntilResult(text: string, methodType: 'URL' | 'UI', waitPerSearch: number = 2000, timeout: number = 20000) {
const attempts = Math.round(timeout/waitPerSearch);
const attempts = Math.round(timeout / waitPerSearch);
let loopCount = 0;
let myPromise = new Promise((resolve, reject) => {
const check = async () => {
loopCount++;
loopCount >= attempts ? reject('File not found') : methodType === 'UI' ? await this.searchFor(text) : await this.searchByURL(text);
await this.searchResult.isPresent(waitPerSearch) ? resolve('File found') : setTimeout(check, waitPerSearch);
}
loopCount++;
loopCount >= attempts ? reject('File not found') : methodType === 'UI' ? await this.searchFor(text) : await this.searchByURL(text);
(await this.searchResult.isPresent(waitPerSearch)) ? resolve('File found') : setTimeout(check, waitPerSearch);
};
return check();
});
return myPromise;
});
return myPromise;
}
}