stevepryde/thirtyfour

Css animated Input and Select fields getting selected or keys input but not being registered by application

Googs55 opened this issue · 1 comments

Hello! I have encountered some problems with animated input and select fields. Not sure how else to describe it other than attaching an image. I have attempted to find and click on fields wait a second then select or send_keys however this was unsuccessful. Has anyone encountered this? Here is the code block in question.

`
let select_org = driver.find_element(By::XPath("//select[1][@Class='select-field typography-body1 typography-greyscale-black']")).await?;
select_org.click().await?;

tokio::time::sleep(Duration::from_secs(1)).await;

let poll_org: Vec<WebElement> = driver.query(By::Css("option")).all().await?;
let x = poll_org.len();
let mut rng = rand::thread_rng();
let y: usize = rng.gen_range(0..x);
poll_org[y].click().await?;

`

Screen Shot 2022-02-02 at 5 34 29 PM

On another note can you please confirm that //select[nth] is the correct way to select the nth element for XPath?

Thank you for the assistance!

~Googs55

This project isn't really the place to answer XPath questions, sorry. I can't help with that part. The thirtyfour side just passes your xpath on to the underlying webdriver.

For the rest, it seems you are searching for <option> elements below the root, rather than below the select_org element you clicked earlier. This would cause it to find all <option> elements on the entire page and click a random one. Perhaps you could change driver.query to select_org.query for the poll_org case?

Also note there is a wrapper for <select> elements: https://docs.rs/thirtyfour/latest/thirtyfour/components/select/struct.SelectElement.html