Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(library): wdi5 assertions without browser service #430

Merged
merged 16 commits into from
Feb 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/lib/wdi5-control.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as util from "util"

import { ELEMENT_KEY as _ELEMENT_KEY } from "webdriverio/build/constants"
vobu marked this conversation as resolved.
Show resolved Hide resolved
import { clientSide_getControl } from "../../client-side-js/getControl"
import { clientSide_interactWithControl } from "../../client-side-js/interactWithControl"
import { clientSide_executeControlMethod } from "../../client-side-js/executeControlMethod"
Expand All @@ -9,7 +9,7 @@ import { clientSide_ui5Response, wdi5ControlMetadata, wdi5Selector } from "../ty
import { Logger as _Logger } from "./Logger"
import { wdioApi } from "./wdioApi"
import { WDI5Object } from "./wdi5-object"

const ELEMENT_KEY = _ELEMENT_KEY
vobu marked this conversation as resolved.
Show resolved Hide resolved
const Logger = _Logger.getInstance()

/**
Expand Down Expand Up @@ -659,6 +659,23 @@ export class WDI5Control {
}

const _result = (await clientSide_getControl(controlSelector, this._browserInstance)) as clientSide_ui5Response

// When chromedriver service is not used the domElement is not set accordingly via devtool protocol
QA-ler marked this conversation as resolved.
Show resolved Hide resolved
// Therefore we get element reference by calling browser execute function manually
if (_result.status === 0 && !_result.domElement[ELEMENT_KEY]) {
const elementReference = (await this._browserInstance.execute((id) => {
const webElement: Node = document.evaluate(
vobu marked this conversation as resolved.
Show resolved Hide resolved
`//*[@id='${id}']`,
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
).singleNodeValue
return webElement
}, _result.id)) as unknown as WebdriverIO.Element
_result.domElement = elementReference
}

const { status, domElement, id, aProtoFunctions, className } = _result

if (status === 0 && id) {
Expand Down