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.
Related
Using Selenium Webdriver on Ruby, is there a way to set up Firefox to be opened on "Responsive Design View" and continue executing tests for the whole session?
I've done it on Google Chrome and it's working fine (sans the touch support part). For Firefox, I've only seen questions around creating preset for screen size but not much activity on how to actually execute tests on said profile.
Please advise.
I have started to learn automation testing and i have come across this concept and its little difficult to understand. I am new to this concept. So..
what is Firefox profiling and how can we change Firefox profile using selenium web driver
Selenium WebDriver launch firefox with a default profile. If you want to launch firefox with your customized settings you can do so by using Firefox Profile.
For Example, if you want to add any extension to firefox you can simply use.
FirefoxProfile fp = new FirefoxProfile();
//fp.addExtension(extensionToInstall);
WebDriver driver = new FirefoxDriver(fp); // here you can launch your webdriver with your customized firefox profile.
Another way to use firefox profile is given here
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
}
}
}
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 web app under tests. And I need to test it from Lunix and Windows with firefox 5 only. So, how can I set particular firefox version in New FirefoxDriver() that Firefox 5 runs only, not Firefox 6 or 9?
I don't want to set path to firefox because it's not useful approach when we have several OS.
Create one firefox 5 profile and just give the name of that profile below. It will launch the given profile browser.
FirefoxProfile profile = new ProfilesIni().getProfile(profileName);
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, profile);
driver = new FirefoxDriver(dc);
refer this link to know how to create firefox profile.