clean up
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
import {browser} from '@wdio/globals';
|
||||
import {browser} from '@wdio/globals';
|
||||
|
||||
export type PageOptions = {
|
||||
browser?: typeof browser; // MultiRemote usecase
|
||||
};
|
||||
|
||||
export type PageOptions = {
|
||||
browser?: typeof browser; // MultiRemote usecase
|
||||
export type PageOpenOptions = {
|
||||
queryParameters?: Record<string, string | number>;
|
||||
isNewTabRequest?: boolean;
|
||||
endpoint?: string;
|
||||
requestPath?: string;
|
||||
};
|
||||
|
||||
}
|
||||
export default class Page {
|
||||
private readonly _baseUrl: string;
|
||||
|
||||
export type PageOpenOptions = {
|
||||
queryParameters?: Record<string, string | number>;
|
||||
isNewTabRequest?: boolean;
|
||||
endpoint?: string;
|
||||
requestPath?: string;
|
||||
};
|
||||
|
||||
export default class Page {
|
||||
private readonly _baseUrl: string;
|
||||
|
||||
constructor(baseUrl: string) {
|
||||
constructor(baseUrl: string) {
|
||||
this._baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public async open(options: PageOpenOptions = {}): Promise<void> {
|
||||
public async open(options: PageOpenOptions = {}): Promise<void> {
|
||||
const {queryParameters, isNewTabRequest, endpoint, requestPath} = options;
|
||||
const pageUrl = `${this._baseUrl}/${endpoint}${requestPath}?${Object.entries(queryParameters ?? {}).map(([queryParameterName, queryParamterValue]) => (`${queryParameterName}=${queryParamterValue}&`)).join('')}`;
|
||||
const pageUrl = `${this._baseUrl}/${endpoint}${requestPath}?${Object.entries(queryParameters ?? {})
|
||||
.map(([queryParameterName, queryParamterValue]) => `${queryParameterName}=${queryParamterValue}&`)
|
||||
.join('')}`;
|
||||
|
||||
if (isNewTabRequest) {
|
||||
await browser.newWindow(pageUrl);
|
||||
} else {
|
||||
await browser.url(pageUrl);
|
||||
}
|
||||
} else {
|
||||
await browser.url(pageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user