Bug 1569100 - Marionette: Add IsDisplayed, IsEnabled and IsSelected commands and Bool response type. r=ato

Differential Revision: https://phabricator.services.mozilla.com/D41187

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nupur Baghel 2019-08-08 11:13:07 +00:00
Родитель dcfecbcd60
Коммит e500fdddbb
3 изменённых файлов: 22 добавлений и 6 удалений

Просмотреть файл

@ -30,6 +30,8 @@ pub struct ElementRect {
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MarionetteResult {
#[serde(deserialize_with = "from_value", serialize_with = "to_value")]
Bool(bool),
#[serde(deserialize_with = "from_value", serialize_with = "to_empty_value")]
Null,
NewWindow(NewWindow),
@ -96,6 +98,11 @@ mod tests {
use crate::test::{assert_de, assert_ser_de, ELEMENT_KEY};
use serde_json::json;
#[test]
fn test_boolean_response() {
assert_ser_de(&MarionetteResult::Bool(true), json!({"value": true}));
}
#[test]
fn test_cookies_response() {
let mut data = Vec::new();

Просмотреть файл

@ -115,6 +115,12 @@ pub enum Command {
GetWindowHandles,
#[serde(rename = "WebDriver:GetWindowRect")]
GetWindowRect,
#[serde(rename = "WebDriver:IsElementDisplayed")]
IsDisplayed(LegacyWebElement),
#[serde(rename = "WebDriver:IsElementEnabled")]
IsEnabled(LegacyWebElement),
#[serde(rename = "WebDriver:IsElementSelected")]
IsSelected(LegacyWebElement),
#[serde(rename = "WebDriver:MaximizeWindow")]
MaximizeWindow,
#[serde(rename = "WebDriver:MinimizeWindow")]

Просмотреть файл

@ -864,6 +864,15 @@ fn try_convert_to_marionette_message(
MarionetteWebDriverCommand::GetWindowRect,
)),
GetTimeouts => Some(Command::WebDriver(MarionetteWebDriverCommand::GetTimeouts)),
IsDisplayed(ref x) => Some(Command::WebDriver(MarionetteWebDriverCommand::IsDisplayed(
x.to_marionette()?,
))),
IsEnabled(ref x) => Some(Command::WebDriver(MarionetteWebDriverCommand::IsEnabled(
x.to_marionette()?,
))),
IsSelected(ref x) => Some(Command::WebDriver(MarionetteWebDriverCommand::IsSelected(
x.to_marionette()?,
))),
MaximizeWindow => Some(Command::WebDriver(
MarionetteWebDriverCommand::MaximizeWindow,
)),
@ -991,12 +1000,6 @@ impl MarionetteCommand {
GetTitle => (Some("WebDriver:GetTitle"), None),
GoBack => (Some("WebDriver:Back"), None),
GoForward => (Some("WebDriver:Forward"), None),
IsDisplayed(ref x) => (
Some("WebDriver:IsElementDisplayed"),
Some(x.to_marionette()),
),
IsEnabled(ref x) => (Some("WebDriver:IsElementEnabled"), Some(x.to_marionette())),
IsSelected(ref x) => (Some("WebDriver:IsElementSelected"), Some(x.to_marionette())),
NewSession(_) => {
let caps = capabilities
.expect("Tried to create new session without processing capabilities");