[services/web_element_wrapper] update clearValue function to fix Firefox tests (#41117) (#41189)

* [services/web_element_wrapper] update clearValue function

* fix flaky test #40670
This commit is contained in:
Dmitry Lemeshko 2019-07-16 00:05:33 +02:00 committed by GitHub
parent 894556c5dd
commit f03f3dd51b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 12 deletions

View file

@ -23,11 +23,11 @@ export default function ({ getService, getPageObjects }) {
const retry = getService('retry');
const find = getService('find');
const pieChart = getService('pieChart');
const renderable = getService('renderable');
const dashboardExpect = getService('dashboardExpect');
const PageObjects = getPageObjects(['common', 'header', 'home', 'dashboard', 'timePicker']);
// FLAKY: https://github.com/elastic/kibana/issues/40670
describe.skip('sample data', function describeIndexTests() {
describe('sample data', function describeIndexTests() {
this.tags('smoke');
before(async () => {
@ -83,6 +83,7 @@ export default function ({ getService, getPageObjects }) {
it('should launch sample flights data set dashboard', async ()=> {
await PageObjects.home.launchSampleDataSet('flights');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
const today = new Date();
const todayYearMonthDay = today.toISOString().substring(0, 10);
const fromTime = `${todayYearMonthDay} 00:00:00.000`;
@ -121,6 +122,7 @@ export default function ({ getService, getPageObjects }) {
it('should launch sample logs data set dashboard', async ()=> {
await PageObjects.home.launchSampleDataSet('logs');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
const today = new Date();
const todayYearMonthDay = today.toISOString().substring(0, 10);
const fromTime = `${todayYearMonthDay} 00:00:00.000`;
@ -133,6 +135,7 @@ export default function ({ getService, getPageObjects }) {
it('should launch sample ecommerce data set dashboard', async ()=> {
await PageObjects.home.launchSampleDataSet('ecommerce');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
const today = new Date();
const todayYearMonthDay = today.toISOString().substring(0, 10);
const fromTime = `${todayYearMonthDay} 00:00:00.000`;

View file

@ -62,7 +62,7 @@ export function ConsolePageProvider({ getService }) {
// while the settings form opens/loads this may fail, so retry for a while
await retry.try(async () => {
const fontSizeInput = await testSubjects.find('setting-font-size-input');
await fontSizeInput.clearValue();
await fontSizeInput.clearValue({ withJS: true });
await fontSizeInput.click();
await fontSizeInput.type(String(newSize));
});

View file

@ -23,6 +23,7 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
const log = getService('log');
const retry = getService('retry');
const find = getService('find');
const browser = getService('browser');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['header']);
@ -53,7 +54,7 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
await testSubjects.click('superDatePickerstartDatePopoverButton');
const panel = await this.getTimePickerPanel();
await testSubjects.click('superDatePickerAbsoluteTab');
await testSubjects.setValue('superDatePickerAbsoluteDateInput', startTime);
await this.inputValue('superDatePickerAbsoluteDateInput', startTime);
await testSubjects.click('superDatePickerstartDatePopoverButton');
await this.waitPanelIsGone(panel);
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
@ -67,6 +68,16 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
await testSubjects.click(commonlyUsedOption);
}
async inputValue(dataTestsubj, value) {
if (browser.isFirefox) {
const input = await testSubjects.find(dataTestsubj);
await input.clearValue();
await input.type(value);
} else {
await testSubjects.setValue(dataTestsubj, value);
}
}
/**
* @param {String} fromTime YYYY-MM-DD HH:mm:ss.SSS
* @param {String} fromTime YYYY-MM-DD HH:mm:ss.SSS
@ -79,14 +90,15 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
await testSubjects.click('superDatePickerendDatePopoverButton');
let panel = await this.getTimePickerPanel();
await testSubjects.click('superDatePickerAbsoluteTab');
await testSubjects.setValue('superDatePickerAbsoluteDateInput', toTime);
await this.inputValue('superDatePickerAbsoluteDateInput', toTime);
// set from time
await testSubjects.click('superDatePickerstartDatePopoverButton');
await this.waitPanelIsGone(panel);
panel = await this.getTimePickerPanel();
await testSubjects.click('superDatePickerAbsoluteTab');
await testSubjects.setValue('superDatePickerAbsoluteDateInput', fromTime);
await this.inputValue('superDatePickerAbsoluteDateInput', fromTime);
const superDatePickerApplyButtonExists = await testSubjects.exists('superDatePickerApplyTimeButton');
if (superDatePickerApplyButtonExists) {

View file

@ -41,6 +41,10 @@ interface TypeOptions {
charByChar: boolean;
}
interface ClearOptions {
withJS: boolean;
}
const RETRY_CLICK_MAX_ATTEMPTS = 3;
const RETRY_CLICK_RETRY_ON_ERRORS = [
'ElementClickInterceptedError',
@ -206,19 +210,23 @@ export class WebElementWrapper {
* is neither a text INPUT element nor a TEXTAREA element.
* https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebElement.html#clear
*
* @return {Promise<void>}
* @param {{ withJS: boolean }} options option to clear input with JS: `arguments[0].value=''`
* @default { withJS: false }
*/
async clearValue() {
// https://bugs.chromium.org/p/chromedriver/issues/detail?id=2702
// await wrapper.webElement.clear();
async clearValue(options: ClearOptions = { withJS: false }) {
await this.retryCall(async function clearValue(wrapper) {
await wrapper.driver.executeScript(`arguments[0].value=''`, wrapper._webElement);
if (wrapper.browserType === Browsers.Chrome || options.withJS) {
// https://bugs.chromium.org/p/chromedriver/issues/detail?id=2702
await wrapper.driver.executeScript(`arguments[0].value=''`, wrapper._webElement);
} else {
await wrapper._webElement.clear();
}
});
}
/**
* Clear the value of this element using Keyboard
* @param {{ charByChar: boolean }} options
* @param {{ charByChar: boolean }} options to input characters one by one
* @default { charByChar: false }
*/
async clearValueWithKeyboard(options: TypeOptions = { charByChar: false }) {