I want to run my Geb specs with firefox driver without opening the browser? can this be done?
Depends on where you are running your tests and what you are trying to achieve.
- If you are running in a *nix system you could use xvfb. It supports both the firefox and chrome drivers which is useful because you want to see your tests fail at the same places it would in an open browser.
- Phantom JS - I personally have used this for our web applications and have found it pretty easy to set up and configure. Mind you this runs on top of WebKit that both Safari and Chrome use to render web pages.
- HtmlUnit - Again built on top a custom Rhino Javascript Engine so you may see different results when running headless and in your browser.
Using your GebConfig.groovy you can configure something like this:
environments {
'headless-ff' {
driver = {
pdriver = new PhantomJSDriver(new DesiredCapabilities())
pdriver.manage().window().maximize()
pdriver
}
}
}
Related
I'm writing Selenium tests in Ruby to test my website in multiple browsers.
However, the tests won't fire correctly unless the cookies are clear(there are triggers I'm testing that only happen X number of times and is stored in a cookie).
Does anyone know how to have selenium open a browser in its private browsing or incognito mode with Selenium or have another idea on how I might solve the issue?
You can get Chrome to start in incognito by default.
There's a solution for Windows at the bottom of the link below... If you're not using Windows, you can Google how to achieve this for you OS =)
https://productforums.google.com/forum/#!topic/chrome/sYaZkNW8II4
I have chromium set as my default browser. Every time I run rspec and capybara my firefox browser opens. I prefer to use chrome/chromium for development and personal use, so how do I get chromium to start opening when I run tests?
You should use chrome driver for capybara. Please have a look at this answer:
https://stackoverflow.com/a/7512626/582792
I am trying to make selenium (web automation test framework) work with firefox in offline mode.
I found this here, which mentions starting selenium with a firefox profile.
Running Selenium RC tests in firefox in offline mode
This is exactly what I am after, but the part I am missing is how to make a firefox profile start in offline mode?
The reason I am wanting to do this is I am using the new HTML5 functionality to allow my application to run offline.
Alternative can this kind of thing be done with Watin?
Solutions
1
Just create and refer to your profile and block your internet connection
2
Maybe this is also helpful:
https://addons.mozilla.org/en-US/firefox/addon/work-offline/
Or simulate the keypress for Data -> Offline Mode in the Firefox menu
3
Or set the network.online > false
in the firefox profile (about:config)
A bit ugly, but working workaround is to set a non existing proxy in profile. Code:
String surelyNotExistingProxyAddress="192.168.100.100:7777";
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(surelyNotExistingProxyAddress)
.setFtpProxy(surelyNotExistingProxyAddress)
.setSslProxy(surelyNotExistingProxyAddress);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver webDriver = new FirefoxDriver(cap);
Then this firefox will load surely nothing from the internet.
I need to automate a task to pull down a set of web pages and process the HTML. Before someone suggests using wget or curl, I need some JS to execute to change the DOM.
I'd like to script Chrome or Firefox to fetch the HTML and render the JS without actually spawning a visual interface. I haven't been able to figure out how to do this.
Does anyone have any suggestions?
Use Selenium RC.
Selenium Remote Control (RC) is a test tool that allows you to write
automated web application UI tests in any programming language against
any HTTP website using any mainstream JavaScript-enabled browser.
I have a webapp which is tested by selenium. Everything works well: writing tests in java, setting breakpoints in my webapp through firebug.
unfortunately I am not able to debug the user-extensions.js it self: After starting the java-test, two firefox windows are opened. One holds the webapp to test, the other one holds the data-flow which uses the user-extensions.
How can I debug the user-extensions?
It seems that it is not possible. I made a workaround and switched the functions to my webapp to debug them there.
It really depends on the browser you're using. I've been able to debug user-extensions using Chrome. In the control Window, you need to right-click and then view the window as a tab. Once you do that, you can activate the developer tools for the control window, which will include the JavaScript debugger.
It's possibile using the Venkman debugger (a separate Firefox extension) and Firefox up until version 32, and that's quite a precious combination.
With Firefox 33 and later, Venkman is broken by api changes, and the native debugger unluckily doesn't allow to debug xul based extensions.