Comments (7)
Btw there isn't a lot of point in doing the selenium calls in parallel because they will be executed sequentially anyway. This is a design decision to make browser testing more predictable but I could see use cases where parallelism might be beneficial, such as this one.
For now you can simplify by doing each request in series and awaiting each time (without join_all()). Otherwise your solution seems to be on the right track. It doesn't look so ugly to me.
Do you actually want the error ones in the list? It seems to me that you probably want to filter by result and collect all the Ok vs Err ones in different vecs.
from thirtyfour.
The mutex is only per webdriver instance so there is no reason why separate webdriver instances could not execute requests in parallel.
Have a read of the Tokio join!
call for more details.
from thirtyfour.
Current ugly solution
let mut future_web_driver_result_option_strings = Vec::new();
for link in new_order_links.iter() {
future_web_driver_result_option_strings.push(link.get_attribute("href"));
}
let web_driver_result_option_strings =
futures::future::join_all(future_web_driver_result_option_strings).await;
let urls = web_driver_result_option_strings
.into_iter()
.map(|wdros| {
if let Ok(Some(url)) = wdros {
return url;
}
"error".to_string()
})
.filter(|url| !enforced_orders.contains(&url))
.collect::<Vec<String>>();
from thirtyfour.
That's probably what I'll end up doing with the errors. I was just quickly trying to set up a scenario where these urls are sent via a multi producer multi consumer channel to other WebDrivers for processing as part of some discovery I'm doing. The enforced_orders vec is instantiated with that error string and only serves to prevent me from sending duplicate urls through the channel.
The links are links to order forms in a queue of orders to be processed, so even if there's an error scraping the link or it's href I'll want to retry until the url is successfully retrieved or the order is no longer in the queue, as the success value of following the link doesn't effect whether I should attempt automation on that order. Not that I bothered sharing any of that context before xD
from thirtyfour.
Hello,
I just wanted to follow up on the discussion of how Selenium handles these calls. I totally see why the individual selenium calls from a single driver ought to be in order. If I connect to a standalone selenium server with /wd/hub and then connect two drivers to it, will calls made by each of those drivers come back asynchronously or in order? I don't really want to mess with docker and/or VMs and whatnot because I'm just running on my local machine, but I really do need the async behavior (I don't want one driver doing nothing because another driver is waiting on the server). Right now I'm spinning up geckodrivers individually on open ports and connecting directly to guarantee async behavior, but this is definitely a hassle.
from thirtyfour.
https://rust-lang.github.io/async-book/06_multiple_futures/01_chapter.html
from thirtyfour.
This makes my life so much easier xD Thank you!
from thirtyfour.
Related Issues (20)
- Error while clicking element. HOT 4
- `#shadow-root` doesn't work on Firefox with geckodriver HOT 1
- Connection refused when using containers HOT 4
- How to use selenium-manager in my code? HOT 2
- thread 'tokio-runtime-worker' panicked at 'internal error: entered unreachable code: received unknown error (no such frame) for NOT_FOUND status code' HOT 4
- How can I set the user-agent for Chromedriver? HOT 3
- Is there a way to use wait_until or something like it to way for a specific ID to be available ? HOT 2
- wait until element to disappear HOT 6
- Chrome Options example erroring HOT 2
- Does `query` work on child elements? HOT 3
- Cannot interact with WebElement HOT 1
- How to trigger onchange event without submitting the form? HOT 2
- How to set PageLoadStrategy::None in DesiredCapabilities::chrome()? HOT 1
- Running the Test without Existing Browser (HtmlUnitDriver) HOT 1
- Add cdp type from auto_generate_cdp crate HOT 2
- How to handle file picker? HOT 4
- How to capture the Chromium's requests and responses traffic using thirtyfour HOT 5
- Maintenance Status
- Device Farm incompatibility - with workaround
- Chromedriver - http incompatibility with hyper HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thirtyfour.