Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

allow command line switches to the webdriver when it starts #469

Closed
jedschneider opened this issue Feb 14, 2013 · 5 comments
Closed

allow command line switches to the webdriver when it starts #469

jedschneider opened this issue Feb 14, 2013 · 5 comments

Comments

@jedschneider
Copy link

It looks as if the Connection class already parses a small subset of options on initialize, it would be nice if we could supply a set of switches that would customize how the webdriver starts up.

At the exact moment it would be really helpful to have the --disable-web-security switch in order to prevent the webdriver from shifting focus when there is an error from an outside library I don't control, like facebook, from taking over the javascript context (see #349). In general, it seems like a nice thing to have.

I'd be happy to implement, but unsure on how to pass the swtiches array to the webdriver. a little guidance and I'll do my best to add this feature, or is there a reason we wouldn't be able to do this?

Thanks!

reference:
http://code.google.com/p/chromedriver/wiki/CapabilitiesAndSwitches
http://peter.sh/experiments/chromium-command-line-switches/

@jferris
Copy link
Member

jferris commented Feb 14, 2013

capybara-webkit uses its own browser implemented on top of QtWebKit, and doesn't use Chrome or webdriver. Are you using the Selenium driver for capybara?

@jedschneider
Copy link
Author

If I understand you correctly we are using the prebuilt capybara-webkit driver, just referencing other webkit based browsers for reference. in our cucumber setup:

Capybara.javascript_driver = :webkit

I also tried running the bin executable directly vendor/bundle/gems/capybara-webkit-0.14.1/bin/webkit_server --disable-web-security but no knowing if this is actually picking up the switch as far as i know.

@jferris
Copy link
Member

jferris commented Feb 14, 2013

Okay, I got confused by the original message.

We consider the webkit_server binary an implementation detail, so we've been exposing configuration through server commands and Ruby methods. You can see a few of them here: http://rubydoc.info/gems/capybara-webkit/Capybara/Webkit/Browser - such as enable_logging and set_skip_image_loading. Any new functionality would be implemented using a similar command.

I did a quick search and couldn't find an obvious analog to --disable-web-security in QtWebKit. This isn't something I want to implement, but I'd accept a tested pull request that adds this functionality. You can do some configuration by exposing commands that change QWebSettings: http://doc-snapshot.qt-project.org/4.8/qwebsettings.html - other things we've had to do some strange hacks to implement. I'm not sure exactly what you'd have to do to achieve the functionality you want, but the Qt docs are a good place to start.

Let me know if you need any more pointers to get started.

@jferris jferris closed this as completed Feb 14, 2013
@jedschneider
Copy link
Author

I think the setting I'd like to experiment with is this one: QWebSettings::XSSAuditingEnabled
I know it says in the description that it is disabled by default but I wonder if the documentation is misleading. I can track the command method back to calling the socket#puts but then I cant really see the matching method, eg 'EnableLogging' defined in the QT api. maybe if i can see where that is defined I can see how it matches back up to the driver. also, any examples of using QWebSettings for other things would be helpful, thanks. I saw the socket debugger class. that sounds handy.

@jferris
Copy link
Member

jferris commented Feb 15, 2013

The pipeline looks roughly like this from that point:

A lot of commands just call something on WebPage. For example, here's the SetSkipImageLoading command: https://github.com/thoughtbot/capybara-webkit/blob/master/src/SetSkipImageLoading.cpp - which calls a method on webpage: https://github.com/thoughtbot/capybara-webkit/blob/master/src/WebPage.cpp#L252 - which uses QWebSettings.

There's a rake task for adding new commands, so you don't have to add all the files by hand. It works like rake generate_command NAME=MySweetCommand. You can edit the generated .cpp file and implement the start method for your command.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants