зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1654609 - [marionette] Port WebDriver:GetElementProperty and WebDriver:GetElementAttribute to JSWindowActor. r=marionette-reviewers,maja_zf
Differential Revision: https://phabricator.services.mozilla.com/D84576
This commit is contained in:
Родитель
201cbd12be
Коммит
37c68db147
|
@ -75,6 +75,12 @@ class MarionetteFrameChild extends JSWindowActorChild {
|
||||||
case "MarionetteFrameParent:findElements":
|
case "MarionetteFrameParent:findElements":
|
||||||
result = await this.findElements(data);
|
result = await this.findElements(data);
|
||||||
break;
|
break;
|
||||||
|
case "MarionetteFrameParent:getElementAttribute":
|
||||||
|
result = await this.getElementAttribute(data);
|
||||||
|
break;
|
||||||
|
case "MarionetteFrameParent:getElementProperty":
|
||||||
|
result = await this.getElementProperty(data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { data: evaluate.toJSON(result) };
|
return { data: evaluate.toJSON(result) };
|
||||||
|
@ -121,4 +127,30 @@ class MarionetteFrameChild extends JSWindowActorChild {
|
||||||
const el = await element.find(container, strategy, selector, opts);
|
const el = await element.find(container, strategy, selector, opts);
|
||||||
return this.seenEls.addAll(el);
|
return this.seenEls.addAll(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of an attribute for the given element.
|
||||||
|
*/
|
||||||
|
async getElementAttribute(options = {}) {
|
||||||
|
const { name, webEl } = options;
|
||||||
|
const el = this.seenEls.get(webEl);
|
||||||
|
|
||||||
|
if (element.isBooleanAttribute(el, name)) {
|
||||||
|
if (el.hasAttribute(name)) {
|
||||||
|
return "true";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return el.getAttribute(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a property for the given element.
|
||||||
|
*/
|
||||||
|
async getElementProperty(options = {}) {
|
||||||
|
const { name, webEl } = options;
|
||||||
|
const el = this.seenEls.get(webEl);
|
||||||
|
|
||||||
|
return typeof el[name] != "undefined" ? el[name] : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,4 +74,18 @@ class MarionetteFrameParent extends JSWindowActorParent {
|
||||||
opts,
|
opts,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getElementAttribute(webEl, name) {
|
||||||
|
return this.sendQuery("MarionetteFrameParent:getElementAttribute", {
|
||||||
|
name,
|
||||||
|
webEl,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async getElementProperty(webEl, name) {
|
||||||
|
return this.sendQuery("MarionetteFrameParent:getElementProperty", {
|
||||||
|
name,
|
||||||
|
webEl,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2253,9 +2253,14 @@ GeckoDriver.prototype.getElementAttribute = async function(cmd) {
|
||||||
assert.open(this.getCurrentWindow());
|
assert.open(this.getCurrentWindow());
|
||||||
await this._handleUserPrompts();
|
await this._handleUserPrompts();
|
||||||
|
|
||||||
let id = assert.string(cmd.parameters.id);
|
const id = assert.string(cmd.parameters.id);
|
||||||
let name = assert.string(cmd.parameters.name);
|
const name = assert.string(cmd.parameters.name);
|
||||||
let webEl = WebElement.fromUUID(id, this.context);
|
const webEl = WebElement.fromUUID(id, this.context);
|
||||||
|
|
||||||
|
if (MarionettePrefs.useActors) {
|
||||||
|
const actor = await this.getActor();
|
||||||
|
return actor.getElementAttribute(webEl, name);
|
||||||
|
}
|
||||||
|
|
||||||
switch (this.context) {
|
switch (this.context) {
|
||||||
case Context.Chrome:
|
case Context.Chrome:
|
||||||
|
@ -2294,9 +2299,14 @@ GeckoDriver.prototype.getElementProperty = async function(cmd) {
|
||||||
assert.open(this.getCurrentWindow());
|
assert.open(this.getCurrentWindow());
|
||||||
await this._handleUserPrompts();
|
await this._handleUserPrompts();
|
||||||
|
|
||||||
let id = assert.string(cmd.parameters.id);
|
const id = assert.string(cmd.parameters.id);
|
||||||
let name = assert.string(cmd.parameters.name);
|
const name = assert.string(cmd.parameters.name);
|
||||||
let webEl = WebElement.fromUUID(id, this.context);
|
const webEl = WebElement.fromUUID(id, this.context);
|
||||||
|
|
||||||
|
if (MarionettePrefs.useActors) {
|
||||||
|
const actor = await this.getActor();
|
||||||
|
return actor.getElementProperty(webEl, name);
|
||||||
|
}
|
||||||
|
|
||||||
switch (this.context) {
|
switch (this.context) {
|
||||||
case Context.Chrome:
|
case Context.Chrome:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче