pub use otter::commands::{MgmtCommand, MgmtResponse};
pub use otter::commands::{MgmtGameInstruction, MgmtGameResponse};
pub use otter::commands::{MgmtGameUpdateMode};
-pub use otter::gamestate::Generation;
+pub use otter::gamestate::{self, Generation};
pub use otter::global::InstanceName;
pub use otter::mgmtchannel::MgmtChannel;
+pub use otter::spec::{Coord, Pos, PosC};
pub type T4d = t4::WebDriver;
pub type WDE = t4::error::WebDriverError;
impl<'g> WindowGuard<'g> {
#[throws(AE)]
- fn find_piece(&'g self, pieceid: &'g str) -> PieceElement<'g> {
+ pub fn find_piece(&'g self, pieceid: &'g str) -> PieceElement<'g> {
let id = format!("use{}", pieceid);
let elem = self.su.driver.find_element(By::Id(&id))?;
PieceElement {
impl<'g> PieceElement<'g> {
#[throws(AE)]
- fn pos(&self) -> WebPos {
+ 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()?;
+ Ok::<_,AE>(PosC([x,y]))
+ })()
+ .with_context(|| self.pieceid.to_owned())
+ .context("read position of piece out of x,y attributes")?
+ }
+
+ #[throws(AE)]
+ pub fn pos(&self) -> WebPos {
(||{
Ok::<_,AE>( todo!() )
})()
{
let mut w = su.w(&alice)?;
w.synch()?;
- let p1 = w.find_element(By::Id("use1.1"))?;
+ 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.text(),
+ p1.get_attribute("x"),
+ p1.get_attribute("y"),
+ p1.posg(),
);
- dbg!(p2.rect()?);
- dbg!(w.find_element(By::Id("use3.1"))?.rect()?);
- dbg!(w.find_element(By::Id("use4.1"))?.rect()?);
w.action_chain()
.move_to_element_center(&p1)