From b11e535aad1f54e56cf50de7d11be11596c97d72 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 31 Dec 2020 00:55:13 +0000 Subject: [PATCH] wip pos thing Signed-off-by: Ian Jackson --- wdriver.rs | 9 +++++---- wdriver/wdt-simple.rs | 9 ++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/wdriver.rs b/wdriver.rs index 836ec68c..91242b58 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -743,7 +743,6 @@ impl<'g> WindowGuard<'g> { let elem = self.su.driver.find_element(By::Id(&id))?; PieceElement { pieceid, elem, - pos: None, w: self, } } @@ -756,7 +755,6 @@ pub struct PieceElement<'g> { pieceid: &'g str, w: &'g WindowGuard<'g>, elem: t4::WebElement<'g>, - pos: Option, } impl<'g> Deref for PieceElement<'g> { @@ -768,8 +766,11 @@ impl<'g> PieceElement<'g> { #[throws(AE)] pub fn posg(&self) -> Pos { (||{ - let x = self.get_attribute("x")?.ok_or(anyhow!("x"))?.parse()?; - let y = self.get_attribute("x")?.ok_or(anyhow!("y"))?.parse()?; + let a = |a| Ok::<_,AE>( + self.get_attribute(a)?.ok_or(anyhow!("{}", a))?.parse()? + ); + let x = a("x")?; + let y = a("y")?; Ok::<_,AE>(PosC([x,y])) })() .with_context(|| self.pieceid.to_owned()) diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index b615bd02..1dc66eb1 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -22,13 +22,8 @@ fn main(){ let p1 = w.find_piece("1.1")?; let p2 = w.find_element(By::Id("use2.1"))?; - dbg!(p1.rect()?, - p1.tag_name(), - p1.class_name(), - p1.id(), - p1.get_attribute("x"), - p1.get_attribute("y"), - p1.posg(), + dbg!( + p1.posg(), ); w.action_chain() -- 2.30.2