Comments (4)
If I understand correctly, the issue you have is that you want to run more than 5 parallel sessions of Chrome.
There are some ways you can do this without any changes to thirtyfour
:
- Use selenium server (standalone or grid) rather than using chromedriver directly. Selenium will take care of running parallel sessions for you.
- Use my Xenon project (which can possibly replace selenium for simple use cases) - however it is in very early stages and definitely not ready for production use.
As for your requests. It is pretty trivial to make WebDriverSession public. However I am still not sure why you need this or how it would help to get more parallel sessions working. It seems more likely this would be misleading for most users, and I want to understand your use case before making any changes here.
Likewise with allowing GenericWebDriver to reuse existing connections. Which connections are you referring to?
GenericWebDriver doesn't really know anything about connections. All it knows is that it has a conn
instance that has a create
and an execute
method. The actual HTTP connection to selenium or webdriver server is managed in ReqwestDriverAsync
or SurfDriverAsync
etc. There really is no persistent "connection" as such. The HTTP client object is reused (for reqwest anyway) but each request to selenium/webdriver is a separate REST request.
I'm happy to elaborate on how these are wired up if you need. The documentation around how everything is wired together is pretty sparse at the moment and it would be good to know which parts need to be expanded.
I am also not sure what you mean by "implementing their own WebDrivers". The only reason I can see to implement your own WebDriver struct is to use a different HTTP client. If you are happy with reqwest (using tokio) or surf (using async-std) then you don't need to do this.
GenericWebDriver is generic over the HTTP client implementation, not generic over WebDriver. The actual WebDriver structs are defined already such as
pub type WebDriver = GenericWebDriver<ReqwestDriverAsync>;
(in src/webdriver.rs
)
The WebDriverSession struct is really just an implementation detail that allows WebElement and related structs to have a reference to the underlying HTTP client and its machinery, so that you can do things like find element from element, and also execute scripts on a particular element (e.g. elem.scroll_into_view()
)
Please provide more detail about what you are trying to do, and I'll see if I can help. Thanks.
from thirtyfour.
Using selenium for my use case feel like a heavyweight I like to interact with WebDriver directly. Chromedriver has limit of 7 simulations TCP connections (some of them might not be usable directly). However one TCP connection can be used for multiple sessions. Unfortunately the GenericWebdriver always creates a new Reqwest client which initialises a new TCP connection.
I've implemented my own version of WebDriver struct where the final result looks like:
pub async fn new<C>(
conn: Arc<dyn RemoteConnectionAsync>,
capabilities: C,
) -> WebDriverResult<Self>
where
C: Serialize,
{
let (session_id, session_capabilities) = start_session(conn.clone(), capabilities).await?;
where you can pass existing request client (which maintains connection pool) when creating a new instance of WebDriver, in my case it's just specific type for reqwest client. Unfortunately to do this I had to fork thirtyfour and make the WebDriverSession
interface public.
Alternative could be to provide another new_with_client
method to generic WebDriver where you could pass already existing client to the WebDriver.
Of course you could try to implement your own struct with RemoteConnectionAsync + RemoteConnectionAsyncCreate
interfaces however since the WebDriver uses the create
function on a generic type internal state cannot be persisted you can go for mut static to persist the state for the client pool but that sound unnecessarily hacky.
from thirtyfour.
Thanks for the explanation. I think I have a better idea of what you are trying to do now. It seems very specific to chromedriver (as it is currently implemented) because other webdrivers do not support multiple sessions this way.
I've made the WebDriverSession
struct public in v0.13.3
. Hopefully that will do what you need.
If you do want to do this using other webdrivers or with more than 7 connections, please do check out my Xenon project.
https://github.com/stevepryde/xenon
I agree that Selenium is more resource-hungry than necessary which is why I created Xenon. It essentially just proxies one or more webdriver sessions through a centralised hub which I assume is similar to what Selenium does, but without using nearly as much cpu or memory. For running multiple sessions via a single chromedriver instance or even multiple sessions with multiple chromedriver instances, Xenon should handle that just fine. I have run the thirtyfour
test suite through it several times and that works. Now if only there was a way to get chrome itself to use less cpu and memory, that would be nice.
from thirtyfour.
Thank you @stevepryde looks good to me 👍
from thirtyfour.
Related Issues (20)
- so, how to get the text value of an element HOT 1
- 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
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.