Skip to content

Commit

Permalink
[7.x] Remove IE support in functional tests (#71285) (#71313)
Browse files Browse the repository at this point in the history
* Remove IE support in functional tests (#71285)

* [ftr] remove ie support

* remove ie integration tests config
# Conflicts:
#	test/functional/config.ie.js
#	test/functional/services/remote/remote.ts

* fix eslint errors

* [services/remote/webdriver] fix eslint error (#71346)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
dmlemeshko and elasticmachine committed Jul 10, 2020
1 parent 693ddbb commit 1d8e67e
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 322 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const schema = Joi.object()

browser: Joi.object()
.keys({
type: Joi.string().valid('chrome', 'firefox', 'ie', 'msedge').default('chrome'),
type: Joi.string().valid('chrome', 'firefox', 'msedge').default('chrome'),

logPollingMs: Joi.number().default(100),
acceptInsecureCerts: Joi.boolean().default(false),
Expand Down
10 changes: 0 additions & 10 deletions test/functional/apps/home/_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'header', 'home', 'timePicker']);
const appsMenu = getService('appsMenu');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');

describe('Kibana browser back navigation should work', function describeIndexTests() {
before(async () => {
await esArchiver.loadIfNeeded('discover');
await esArchiver.loadIfNeeded('logstash_functional');
if (browser.isInternetExplorer) {
await kibanaServer.uiSettings.replace({ 'state:storeInSessionStorage': false });
}
});

after(async () => {
if (browser.isInternetExplorer) {
await kibanaServer.uiSettings.replace({ 'state:storeInSessionStorage': true });
}
});

it('detect navigate back issues', async () => {
Expand Down
48 changes: 0 additions & 48 deletions test/functional/config.ie.js

This file was deleted.

7 changes: 0 additions & 7 deletions test/functional/page_objects/time_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ export function TimePickerProvider({ getService, getPageObjects }: FtrProviderCo
const input = await testSubjects.find(dataTestSubj);
await input.clearValue();
await input.type(value);
} else if (browser.isInternetExplorer) {
const input = await testSubjects.find(dataTestSubj);
const currentValue = await input.getAttribute('value');
await input.type(browser.keys.ARROW_RIGHT.repeat(currentValue.length));
await input.type(browser.keys.BACK_SPACE.repeat(currentValue.length));
await input.type(value);
await input.click();
} else {
await testSubjects.setValue(dataTestSubj, value);
}
Expand Down
97 changes: 22 additions & 75 deletions test/functional/services/common/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
);
});

const isW3CEnabled = (driver as any).executor_.w3c === true;

return new (class BrowserService {
/**
* Keyboard events
Expand All @@ -59,19 +57,12 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {

public readonly isFirefox: boolean = browserType === Browsers.Firefox;

public readonly isInternetExplorer: boolean = browserType === Browsers.InternetExplorer;

/**
* Is WebDriver instance W3C compatible
*/
isW3CEnabled = isW3CEnabled;

/**
* Returns instance of Actions API based on driver w3c flag
* https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebDriver.html#actions
*/
public getActions() {
return this.isW3CEnabled ? driver.actions() : driver.actions({ bridge: true });
return driver.actions();
}

/**
Expand Down Expand Up @@ -170,12 +161,7 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
*/
public async getCurrentUrl() {
// strip _t=Date query param when url is read
let current: string;
if (this.isInternetExplorer) {
current = await driver.executeScript('return window.document.location.href');
} else {
current = await driver.getCurrentUrl();
}
const current = await driver.getCurrentUrl();
const currentWithoutTime = modifyUrl(current, (parsed) => {
delete (parsed.query as any)._t;
return void 0;
Expand Down Expand Up @@ -212,15 +198,8 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
* @return {Promise<void>}
*/
public async moveMouseTo(point: { x: number; y: number }): Promise<void> {
if (this.isW3CEnabled) {
await this.getActions().move({ x: 0, y: 0 }).perform();
await this.getActions().move({ x: point.x, y: point.y, origin: Origin.POINTER }).perform();
} else {
await this.getActions()
.pause(this.getActions().mouse)
.move({ x: point.x, y: point.y, origin: Origin.POINTER })
.perform();
}
await this.getActions().move({ x: 0, y: 0 }).perform();
await this.getActions().move({ x: point.x, y: point.y, origin: Origin.POINTER }).perform();
}

/**
Expand All @@ -235,44 +214,20 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
from: { offset?: { x: any; y: any }; location: any },
to: { offset?: { x: any; y: any }; location: any }
) {
if (this.isW3CEnabled) {
// The offset should be specified in pixels relative to the center of the element's bounding box
const getW3CPoint = (data: any) => {
if (!data.offset) {
data.offset = {};
}
return data.location instanceof WebElementWrapper
? { x: data.offset.x || 0, y: data.offset.y || 0, origin: data.location._webElement }
: { x: data.location.x, y: data.location.y, origin: Origin.POINTER };
};

const startPoint = getW3CPoint(from);
const endPoint = getW3CPoint(to);
await this.getActions().move({ x: 0, y: 0 }).perform();
return await this.getActions().move(startPoint).press().move(endPoint).release().perform();
} else {
// The offset should be specified in pixels relative to the top-left corner of the element's bounding box
const getOffset: any = (offset: { x: number; y: number }) =>
offset ? { x: offset.x || 0, y: offset.y || 0 } : { x: 0, y: 0 };

if (from.location instanceof WebElementWrapper === false) {
throw new Error('Dragging point should be WebElementWrapper instance');
} else if (typeof to.location.x === 'number') {
return await this.getActions()
.move({ origin: from.location._webElement })
.press()
.move({ x: to.location.x, y: to.location.y, origin: Origin.POINTER })
.release()
.perform();
} else {
return await new LegacyActionSequence(driver)
.mouseMove(from.location._webElement, getOffset(from.offset))
.mouseDown()
.mouseMove(to.location._webElement, getOffset(to.offset))
.mouseUp()
.perform();
// The offset should be specified in pixels relative to the center of the element's bounding box
const getW3CPoint = (data: any) => {
if (!data.offset) {
data.offset = {};
}
}
return data.location instanceof WebElementWrapper
? { x: data.offset.x || 0, y: data.offset.y || 0, origin: data.location._webElement }
: { x: data.location.x, y: data.location.y, origin: Origin.POINTER };
};

const startPoint = getW3CPoint(from);
const endPoint = getW3CPoint(to);
await this.getActions().move({ x: 0, y: 0 }).perform();
return await this.getActions().move(startPoint).press().move(endPoint).release().perform();
}

/**
Expand Down Expand Up @@ -339,19 +294,11 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
* @return {Promise<void>}
*/
public async clickMouseButton(point: { x: number; y: number }) {
if (this.isW3CEnabled) {
await this.getActions().move({ x: 0, y: 0 }).perform();
await this.getActions()
.move({ x: point.x, y: point.y, origin: Origin.POINTER })
.click()
.perform();
} else {
await this.getActions()
.pause(this.getActions().mouse)
.move({ x: point.x, y: point.y, origin: Origin.POINTER })
.click()
.perform();
}
await this.getActions().move({ x: 0, y: 0 }).perform();
await this.getActions()
.move({ x: point.x, y: point.y, origin: Origin.POINTER })
.click()
.perform();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const RETRY_CLICK_RETRY_ON_ERRORS = [
export class WebElementWrapper {
private By = By;
private Keys = Key;
public isW3CEnabled: boolean = (this.driver as any).executor_.w3c === true;
public isChromium: boolean = [Browsers.Chrome, Browsers.ChromiumEdge].includes(this.browserType);

public static create(
Expand Down Expand Up @@ -141,7 +140,7 @@ export class WebElementWrapper {
}

private getActions() {
return this.isW3CEnabled ? this.driver.actions() : this.driver.actions({ bridge: true });
return this.driver.actions();
}

/**
Expand Down Expand Up @@ -233,9 +232,6 @@ export class WebElementWrapper {
* @default { withJS: false }
*/
async clearValue(options: ClearOptions = { withJS: false }) {
if (this.browserType === Browsers.InternetExplorer) {
return this.clearValueWithKeyboard();
}
await this.retryCall(async function clearValue(wrapper) {
if (wrapper.isChromium || options.withJS) {
// https://bugs.chromium.org/p/chromedriver/issues/detail?id=2702
Expand All @@ -252,16 +248,6 @@ export class WebElementWrapper {
* @default { charByChar: false }
*/
async clearValueWithKeyboard(options: TypeOptions = { charByChar: false }) {
if (this.browserType === Browsers.InternetExplorer) {
const value = await this.getAttribute('value');
// For IE testing, the text field gets clicked in the middle so
// first go HOME and then DELETE all chars
await this.pressKeys(this.Keys.HOME);
for (let i = 0; i <= value.length; i++) {
await this.pressKeys(this.Keys.DELETE);
}
return;
}
if (options.charByChar === true) {
const value = await this.getAttribute('value');
for (let i = 0; i <= value.length; i++) {
Expand Down Expand Up @@ -429,19 +415,11 @@ export class WebElementWrapper {
public async moveMouseTo(options = { xOffset: 0, yOffset: 0 }) {
await this.retryCall(async function moveMouseTo(wrapper) {
await wrapper.scrollIntoViewIfNecessary();
if (wrapper.isW3CEnabled) {
await wrapper.getActions().move({ x: 0, y: 0 }).perform();
await wrapper
.getActions()
.move({ x: options.xOffset, y: options.yOffset, origin: wrapper._webElement })
.perform();
} else {
await wrapper
.getActions()
.pause(wrapper.getActions().mouse)
.move({ x: options.xOffset, y: options.yOffset, origin: wrapper._webElement })
.perform();
}
await wrapper.getActions().move({ x: 0, y: 0 }).perform();
await wrapper
.getActions()
.move({ x: options.xOffset, y: options.yOffset, origin: wrapper._webElement })
.perform();
});
}

Expand All @@ -456,21 +434,12 @@ export class WebElementWrapper {
public async clickMouseButton(options = { xOffset: 0, yOffset: 0 }) {
await this.retryCall(async function clickMouseButton(wrapper) {
await wrapper.scrollIntoViewIfNecessary();
if (wrapper.isW3CEnabled) {
await wrapper.getActions().move({ x: 0, y: 0 }).perform();
await wrapper
.getActions()
.move({ x: options.xOffset, y: options.yOffset, origin: wrapper._webElement })
.click()
.perform();
} else {
await wrapper
.getActions()
.pause(wrapper.getActions().mouse)
.move({ x: options.xOffset, y: options.yOffset, origin: wrapper._webElement })
.click()
.perform();
}
await wrapper.getActions().move({ x: 0, y: 0 }).perform();
await wrapper
.getActions()
.move({ x: options.xOffset, y: options.yOffset, origin: wrapper._webElement })
.click()
.perform();
});
}

Expand Down
1 change: 0 additions & 1 deletion test/functional/services/remote/browsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@
export enum Browsers {
Chrome = 'chrome',
Firefox = 'firefox',
InternetExplorer = 'ie',
ChromiumEdge = 'msedge',
}
10 changes: 1 addition & 9 deletions test/functional/services/remote/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,9 @@ export async function RemoteProvider({ getService }: FtrProviderContext) {
};

const { driver, consoleLog$ } = await initWebDriver(log, browserType, lifecycle, browserConfig);

const isW3CEnabled = (driver as any).executor_.w3c;

const caps = await driver.getCapabilities();
const browserVersion = caps.get(isW3CEnabled ? 'browserVersion' : 'version');

log.info(
`Remote initialized: ${caps.get(
'browserName'
)} ${browserVersion}, w3c compliance=${isW3CEnabled}`
);
log.info(`Remote initialized: ${caps.get('browserName')} ${caps.get('browserVersion')}`);

if ([Browsers.Chrome, Browsers.ChromiumEdge].includes(browserType)) {
log.info(
Expand Down
Loading

0 comments on commit 1d8e67e

Please sign in to comment.