chiark / gitweb /
apitest: Break out HtmlExt::element()
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 26 Feb 2021 00:58:17 +0000 (00:58 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 26 Feb 2021 01:06:22 +0000 (01:06 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-otter.rs

index bb09c6cb2eeac05f37ea43e5aa7c2527dcb9525a..c1ca5c94193ef08e5a74910f8052ad27d72aeaea 100644 (file)
@@ -35,13 +35,22 @@ mod scraper_ext {
     fn select<'a,'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b>;
 
     #[throws(as Option)]
-    fn e_attr<S>(&self, sel: S, attr: &str) -> &str
+    fn element<S>(&self, sel: S) -> ElementRef
     where S: TryInto<Selector>,
           <S as TryInto<Selector>>::Error: Debug,
     {
       self
         .select(&sel.try_into().unwrap())
         .next()?
+    }
+
+    #[throws(as Option)]
+    fn e_attr<S>(&self, sel: S, attr: &str) -> &str
+    where S: TryInto<Selector>,
+          <S as TryInto<Selector>>::Error: Debug,
+    {
+      self
+        .element(sel).unwrap()
         .value().attr(attr)?
     }
   }