Comments (7)
Thanks for the idea of not using from_str
, I changed it to:
let arg = json!({"args": ["-headless"]});
Yeah, re-exporting maplit
might be a bit excessive. I'll make the PR to re-export the other libs.
from fantoccini.
Ah, yes, I'd forgotten about json!
. Maybe we do something like
pub mod ext {
pub use serde_json::{json, Value};
pub use webdriver::capabilities::Capabilities;
}
from fantoccini.
You can construct the json::Value
directly (rather than relying on from_str
), but I agree with you it's pretty inconvenient. Part of the reason there isn't a better API is that the capabilities can take on different forms for different vendors, so I don't know of a good way to expose it beyond just serde_json::Value
. This could perhaps be helped somewhat by fantoccini
re-exporting serde_json::Value
and webdriver::capabilities::Capabilities
? Did you have a particular API in mind that you think would be better? I'd be happy to review a PR!
from fantoccini.
Re-exporting would be a sort of quick fix, but I don't know if its considered a good or bad practice. I would be inclined to go against it.
Ideally I would just change with_capabilities
to receive something like a FancocciniCapabilities
and then internally make it into a Capabilities
.
from fantoccini.
I'm inclined to re-export since we don't actually need our own wrapper functions or anything here. It's unclear what we gain from exposing our own. In your particular case, the maplit
crate may be a good thing to look into too. Re-exporting that seems excessive though 🤔
from fantoccini.
Hi I want to use
with_capabilities
to create a new client, but not sure if doing it right. This is what I'm doing:extern crate tokio; extern crate futures; extern crate fantoccini; extern crate webdriver; extern crate serde_json; use fantoccini::{Client, Locator}; use futures::future::Future; use webdriver::capabilities::Capabilities; fn main() { let mut cap = Capabilities::new(); let arg = serde_json::from_str("{\"args\": [\"-headless\"]}").unwrap(); cap.insert("moz:firefoxOptions".to_string(), arg); let c = Client::with_capabilities("http://localhost:4444", cap); // rest of the code down here... }If this is the right way to do it I was wondering if we could receive in the capabilities in another way that didn't involve me knowing about
webdriver
andserde_json
and having to add them to my dependencies.I'm open to making a PR if you prefer to discuss over actual code.
Hi Amin,
Your reply was incredibly helpful to my understanding of adding capabilities but I am wondering where you found the "moz:firefoxOptions" string at. I am currently trying to replicate this but using Chromedriver and I haven't had much luck with it. Thank you for your time!
from fantoccini.
Hi @Grav3y sadly I didn't document where I got it, but this links might be useful
- https://chromedriver.chromium.org/capabilities
- https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities#Vendor-specific_capabilities
- https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions#Example
That project I never got to implementing the capabilities for a Chromedriver so not much else I can do to help you
from fantoccini.
Related Issues (20)
- Cannot set `pageLoadOptions` in capabilities HOT 2
- WebAuthn support HOT 1
- BrowserStack requires `charset=utf-8` in `Content-Type` header on Selenium >= 4 HOT 1
- 👋 From the Selenium project! HOT 1
- Cannot access error variant information from webdriver::ErrorStatus enum HOT 1
- `Session::with_capabilities_and_connector` hides the WebDriver response HOT 1
- What's happening here? (fantoccini breaks String + &String) HOT 10
- Error when connecting to browserstack: Session not started or terminated HOT 1
- Test whether text is visible? HOT 3
- excute() doesnt execute some scripts correctly HOT 3
- SessionNotCreated error on second run with fantoccini and geckodriver HOT 1
- How to specify options for webdriver? HOT 1
- An error occurs in the IE mode of the Edge browser. HOT 2
- Testing of client&server-side Rust interaction HOT 1
- returning Prototype.Array shows in console.log but nothing from println. HOT 1
- Can you automate the geckodriver session initialization? HOT 2
- Please add Network Request Interception HOT 1
- Get console log messages HOT 1
- webdriver might be part of public API HOT 1
- WheelActions needed HOT 2
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 fantoccini.