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

Get prop naturalWidth of img, get a error Json("Unexpected value for property: Number(450)") #233

Open
wccyzxy opened this issue Jul 11, 2024 · 0 comments

Comments

@wccyzxy
Copy link

wccyzxy commented Jul 11, 2024

The code to get prop naturalWidth of img element:

let question_img = question_img_div.find(By::Css("img")).await?;
let origin_width= question_img.prop("naturalWidth").await?;

The error is:

Error: Json("Unexpected value for property: Number(450)")

Goto the code of prop function:

    pub async fn prop(&self, name: impl Into<String>) -> WebDriverResult<Option<String>> {
        let resp = self
            .handle
            .cmd(Command::GetElementProperty(self.element_id.clone(), name.into()))
            .await?;
        match resp.value()? {
            Value::String(v) => Ok(Some(v)),
            Value::Bool(b) => Ok(Some(b.to_string())),
            Value::Null => Ok(None),
            v => Err(WebDriverError::Json(format!("Unexpected value for property: {:?}", v))),
        }
    }

It's not consider Number type.
It's a bug? or the way to use is not correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant