mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* [services/lib/web_element_wrapper] set custom wait for findAll * [services/remote] print browser name and version on init * [services/combo_box] fix return statement * fix lint error
This commit is contained in:
parent
203897c647
commit
d715511708
3 changed files with 65 additions and 21 deletions
|
@ -18,11 +18,14 @@
|
|||
*/
|
||||
|
||||
export function ComboBoxProvider({ getService }) {
|
||||
const config = getService('config');
|
||||
const testSubjects = getService('testSubjects');
|
||||
const find = getService('find');
|
||||
const log = getService('log');
|
||||
const retry = getService('retry');
|
||||
|
||||
const WAIT_FOR_EXISTS_TIME = config.get('timeouts.waitForExists');
|
||||
|
||||
// wrapper around EuiComboBox interactions
|
||||
class ComboBox {
|
||||
|
||||
|
@ -38,7 +41,10 @@ export function ComboBoxProvider({ getService }) {
|
|||
await this.openOptionsList(comboBoxElement);
|
||||
|
||||
if (value !== undefined) {
|
||||
const options = await find.allByCssSelector(`.euiFilterSelectItem[title^="${value.toString().trim()}"]`);
|
||||
const options = await find.allByCssSelector(
|
||||
`.euiFilterSelectItem[title^="${value.toString().trim()}"]`,
|
||||
WAIT_FOR_EXISTS_TIME
|
||||
);
|
||||
|
||||
if (options.length > 0) {
|
||||
await options[0].click();
|
||||
|
@ -92,15 +98,15 @@ export function ComboBoxProvider({ getService }) {
|
|||
async doesComboBoxHaveSelectedOptions(comboBoxSelector) {
|
||||
log.debug(`comboBox.doesComboBoxHaveSelectedOptions, comboBoxSelector: ${comboBoxSelector}`);
|
||||
const comboBox = await testSubjects.find(comboBoxSelector);
|
||||
const selectedOptions = await comboBox.findAllByClassName('euiComboBoxPill');
|
||||
return selectedOptions > 0;
|
||||
const selectedOptions = await comboBox.findAllByClassName('euiComboBoxPill', WAIT_FOR_EXISTS_TIME);
|
||||
return selectedOptions.length > 0;
|
||||
}
|
||||
|
||||
async getComboBoxSelectedOptions(comboBoxSelector) {
|
||||
log.debug(`comboBox.getComboBoxSelectedOptions, comboBoxSelector: ${comboBoxSelector}`);
|
||||
return await retry.try(async () => {
|
||||
const comboBox = await testSubjects.find(comboBoxSelector);
|
||||
const selectedOptions = await comboBox.findAllByClassName('euiComboBoxPill');
|
||||
const selectedOptions = await comboBox.findAllByClassName('euiComboBoxPill', WAIT_FOR_EXISTS_TIME);
|
||||
if (selectedOptions.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
@ -132,8 +138,11 @@ export function ComboBoxProvider({ getService }) {
|
|||
}
|
||||
|
||||
async doesClearButtonExist(comboBoxElement) {
|
||||
return await find.exists(
|
||||
async () => await comboBoxElement.findByCssSelector('[data-test-subj="comboBoxClearButton"]'));
|
||||
const found = await comboBoxElement.findAllByCssSelector(
|
||||
'[data-test-subj="comboBoxClearButton"]',
|
||||
WAIT_FOR_EXISTS_TIME
|
||||
);
|
||||
return found.length > 0;
|
||||
}
|
||||
|
||||
async closeOptionsList(comboBoxElement) {
|
||||
|
|
|
@ -40,6 +40,17 @@ export class WebElementWrapper {
|
|||
this._logger = log;
|
||||
}
|
||||
|
||||
async _findWithCustomTimeout(findFunction, timeout) {
|
||||
if (timeout && timeout !== this._defaultFindTimeout) {
|
||||
await this._driver.manage().setTimeouts({ implicit: timeout });
|
||||
}
|
||||
const elements = await findFunction();
|
||||
if (timeout && timeout !== this._defaultFindTimeout) {
|
||||
await this._driver.manage().setTimeouts({ implicit: this._defaultFindTimeout });
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
_wrap(otherWebElement) {
|
||||
return new WebElementWrapper(otherWebElement, this._webDriver, this._defaultFindTimeout, this._fixedHeaderHeight, this._logger);
|
||||
}
|
||||
|
@ -286,10 +297,16 @@ export class WebElementWrapper {
|
|||
* https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebElement.html#findElement
|
||||
*
|
||||
* @param {string} selector
|
||||
* @param {number} timeout
|
||||
* @return {Promise<WebElementWrapper[]>}
|
||||
*/
|
||||
async findAllByCssSelector(selector) {
|
||||
return this._wrapAll(await this._webElement.findElements(this._By.css(selector)));
|
||||
async findAllByCssSelector(selector, timeout) {
|
||||
return this._wrapAll(
|
||||
await this._findWithCustomTimeout(
|
||||
async () => await this._webElement.findElements(this._By.css(selector)),
|
||||
timeout
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,11 +325,15 @@ export class WebElementWrapper {
|
|||
* https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebElement.html#findElement
|
||||
*
|
||||
* @param {string} className
|
||||
* @param {number} timeout
|
||||
* @return {Promise<WebElementWrapper[]>}
|
||||
*/
|
||||
async findAllByClassName(className) {
|
||||
return await this._wrapAll(
|
||||
await this._webElement.findElements(this._By.className(className))
|
||||
async findAllByClassName(className, timeout) {
|
||||
return this._wrapAll(
|
||||
await this._findWithCustomTimeout(
|
||||
async () => await this._webElement.findElements(this._By.className(className)),
|
||||
timeout
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -332,11 +353,15 @@ export class WebElementWrapper {
|
|||
* https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebElement.html#findElement
|
||||
*
|
||||
* @param {string} tagName
|
||||
* @param {number} timeout
|
||||
* @return {Promise<WebElementWrapper[]>}
|
||||
*/
|
||||
async findAllByTagName(tagName) {
|
||||
return await this._wrapAll(
|
||||
await this._webElement.findElements(this._By.tagName(tagName))
|
||||
async findAllByTagName(tagName, timeout) {
|
||||
return this._wrapAll(
|
||||
await this._findWithCustomTimeout(
|
||||
async () => await this._webElement.findElements(this._By.tagName(tagName)),
|
||||
timeout
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -356,11 +381,15 @@ export class WebElementWrapper {
|
|||
* https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebElement.html#findElement
|
||||
*
|
||||
* @param {string} selector
|
||||
* @param {number} timeout
|
||||
* @return {Promise<WebElementWrapper[]>}
|
||||
*/
|
||||
async findAllByXpath(selector) {
|
||||
return await this._wrapAll(
|
||||
await this._webElement.findElements(this._By.xpath(selector))
|
||||
async findAllByXpath(selector, timeout) {
|
||||
return this._wrapAll(
|
||||
await this._findWithCustomTimeout(
|
||||
async () => await this._webElement.findElements(this._By.xpath(selector)),
|
||||
timeout
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -380,11 +409,15 @@ export class WebElementWrapper {
|
|||
* https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebElement.html#findElement
|
||||
*
|
||||
* @param {string} selector
|
||||
* @param {number} timeout
|
||||
* @return {Promise<WebElementWrapper[]>}
|
||||
*/
|
||||
async findAllByPartialLinkText(linkText) {
|
||||
return await this._wrapAll(
|
||||
await this._webElement.findElements(this._By.partialLinkText(linkText))
|
||||
async findAllByPartialLinkText(linkText, timeout) {
|
||||
return this._wrapAll(
|
||||
await this._findWithCustomTimeout(
|
||||
async () => await this._webElement.findElements(this._By.partialLinkText(linkText)),
|
||||
timeout
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,10 @@ export async function RemoteProvider({ getService }: FtrProviderContext) {
|
|||
}
|
||||
|
||||
const { driver, By, Key, until, LegacyActionSequence } = await initWebDriver(log, browserType);
|
||||
const caps = await driver.getCapabilities();
|
||||
const browserVersion = caps.get(browserType === 'chrome' ? 'version' : 'browserVersion');
|
||||
|
||||
log.info('Remote initialized');
|
||||
log.info(`Remote initialized: ${caps.get('browserName')} ${browserVersion}`);
|
||||
|
||||
lifecycle.on('beforeTests', async () => {
|
||||
// hard coded default, can be overridden per suite using `browser.setWindowSize()`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue