switched over to matching for css selector

This commit is contained in:
spv 2024-08-24 14:26:21 +02:00
parent 85011038fa
commit 857a81478a
No known key found for this signature in database
GPG Key ID: 7638A987CE28ADFA

View File

@ -1,8 +1,15 @@
use fantoccini::{ClientBuilder, Locator}; use fantoccini::{elements::Element, ClientBuilder, Locator};
const MAX_ANSWER_INDEX: u128 = 100000000;
struct Answer {
upvotes: u32,
author: String,
content: String,
}
// let's set up the sequence of steps we want the browser to take // let's set up the sequence of steps we want the browser to take
#[tokio::main] async fn get_answer() -> anyhow::Result<Element> {
async fn main() -> Result<(), fantoccini::error::CmdError> {
let c = ClientBuilder::native() let c = ClientBuilder::native()
.connect("http://localhost:4444") .connect("http://localhost:4444")
.await .await
@ -11,9 +18,13 @@ async fn main() -> Result<(), fantoccini::error::CmdError> {
// first, go to the Wikipedia page for Foobar // first, go to the Wikipedia page for Foobar
c.goto("https://stackoverflow.com/questions/78872368/how-to-set-up-webpack-devserver-config-to-build-another-target").await?; c.goto("https://stackoverflow.com/questions/78872368/how-to-set-up-webpack-devserver-config-to-build-another-target").await?;
// click "Foo (disambiguation)" let answer_loc = c.find(Locator::Css("answer")).await;
let answer_loc = c.find(Locator::Id("answer-.*")).await?;
dbg!(answer_loc);
c.close().await c.close().await;
Ok(answer_loc?)
}
#[tokio::main]
async fn main() {
dbg!(get_answer().await);
} }