from this answer
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.download.folderList",2);
firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false);
firefoxProfile.setPreference("browser.download.dir","c:\\downloads");
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv");
WebDriver driver = new FirefoxDriver(firefoxProfile);
How can I set properties like browser.download.manager.showWhenStarting when using nightwatch?
From my understanding the only way to accomplish this is to create a profile before hand and use that profile in nightwatch configuration, similar to the insructions here: https://github.com/nightwatchjs/nightwatch/wiki/Enable-Firebug-in-Firefox-for-Nightwatch-tests
I wish there was a way to set firefox preferences, since with the solution I'm providing your tests are dependent on running on the machine with the profile.
Related
Basically I'm trying out Selenium webdriver (using FireFox) and right now I am trying to sign up to a Google account.
However, the strange thing is that whenever I run Selenium and let it use the (empty I assume?) Selenium FireFox profile Google seems to detect it and block me (asking for phone vertification).
This is even the case when I load up the selenium profile and manually sign up.
When I sign up manually (and don't use the selenium profile) I can sign up just fine.
Is the Selenium FireFox profile some how special which enables the servers to detect it?
EDIT: I'm trying to startup selenium with my default FF profile (however it keeps starting up in an empty profile) - here's the code:
OpenQA.Selenium.Proxy proxySetting = new OpenQA.Selenium.Proxy();
proxySetting.HttpProxy = proxy;
proxySetting.FtpProxy = proxy;
proxySetting.SslProxy = proxy;
FirefoxProfile profile = new FirefoxProfile("default");
profile.SetProxyPreferences(proxySetting);
profile.SetPreference("browser.privatebrowsing.autostart", true);
_driver = new FirefoxDriver(profile);
EDIT:
I managed to open the default firefox profile but now it doesn't use my proxy settings. How can I use the normal profile and still customize the profile proxies?
This post talks about an HtmlDriver tag being added to the HTML in the FirefoxDriver which would be a dead giveaway
Google is a strong supporter of Open Source, and even Selenium itself, however I don't think Google would particularly condone a Selenium script creating a bunch of spam accounts that probably would never be used, and just take space.
That being said, I believe that it would be possible potentially.
The only way that Google would be able to know you are using Selenium, is based on the Request Headers. It's possible either the User-Agent has something to do with Selenium, or one of the other Headers.
My solution would be to use something like Fiddler to listen to the requests that Firefox is sending, and then edit your Selenium scripts to account for, and change those requests so Google does not know that you are using Selenium.
This most likely goes against their terms of use, so exercise caution, and use this answer for educational purposes only.
Is there a chance, if you were using the complete path to your firefox profile directory? (e.g. C:\Users\???\AppData\Roaming\Mozilla\Firefox\Profiles\your_profile.default)
While executing a scenario, I need to launch a new tab within a browser and execute my script. Can we able to achieve it using Cucumber Page Object.
Also I need to interact with old and new tab intermittently. Please help me to solve this issue. Thanks.
If your test launches the new tab as part of its actions then this answer should help you to switch to the new tab - Controlling new tab to operate using Watir? (Ruby)
If you want to open a new browser instance to complete some other part of the test then you can just create a second browser with watir. e.g.
#browser = Watir::Browser.new :firefox
#second_browser = Watir::Browser.new :firefox
and then pass in the relevant browser instance to your page object constructor
my_page_object = MyPageObjectClass.new(#second_browser)
Try using something like this:
page.driver.browser.switch_to.window (page.driver.browser.window_handles.last)
switch_to is a selenium method that allows you to change context to a new window. window_handles is a list of currently open windows.
More details in Selenium docs in the section "Moving Between Windows and Frames". The docs are for javascript, but there are also Ruby Bindings.
I am running tests on a location-aware site. I can tell Chrome or IE to always allow geo-locate for that one page, but Firefox always forgets once I close the browser.
Anyone else ever encounter this?
The Selenium driver for Firefox seems to create a new, anonymous profile with each run by default. Hence your settings won't persist, as they will be discarded together with the profile after a run.
You should:
Set up your FirefoxProfile instance to use .setPreference("geo.prompt.testing", true); and .setPreference("geo.prompt.testing.allow", true);.
or set up an existing profile with the either the above preferences or explicitly allow your site. Then set the webdriver.firefox.profile Java System property or use the public FirefoxProfile(File profileDir) constructor to use that existing profile.
right I have hit a wall using the Selenium Maven Plugin - using the selenese goal which is all swell - however when it comes to executing the tests in firefox, the plugin launches a fresh firefox profile, which doesn't have the company proxy configured.
Now if i were simply executing my html suite directly with the selenium server jar I could specify a firefox profile - however it appears to be the case this has not been included in as a parameter in the selenese goal for this plugin. madness!
there are such parameters for the start-server goal, so why not selenese?
Has anybody else faced this issue? Any workarounds?
Appreciate all sensible input.
Thanks,
I thought I would post my solution should anyone else come accross this...
Simply need to get the selenium maven plugin source, and patch it. The constants are available in the selenium server RemoteControlConfiguration class however this plugin doesn't make use of them all in the SeleneseMojo. So it is a very simple fix:
Set the properties that we want to change when the seleneseMojo starts the selenium server. So in this case I wanted to make use of firefoxProfileTemplate so I did this:
def conf = new RemoteControlConfiguration()
conf.port = port
conf.singleWindow = !multiWindow
conf.firefoxProfileTemplate = firefoxProfileTemplate
def server = new SeleniumServer(slowResources, conf)
server.start()
Now I can specify a firefoxProfileTemplate value in my maven project execution configurations and therefore specify a firefox profile when running selenium html suites through maven.
I know that with watir-WebDriver, I can make use of RubyBindings to have the browser load specific profiles or Firefox add-ons when I create a new browser instance. However, can I use Watir to actually use the add-on(s) I open?
The reason I ask is that I am trying to implement a web scraper to navigate to websites and record HTTP interactions. However, since Tamper Data already does the HTTP request/response logging I require, I'd rather use its functionality instead of having to redo it myself.
If this is not possible, I'm wondering if anyone knows a unit tester that will allow me to:
Open a Firefox browser & load Tamper Data
Navigate to specified pages
Click a button on Tamper Data's UI
You can't interact with extensions using bare watir/webdriver as far as i know, need to find a workaround ... Try something like rautomation - https://github.com/jarmo/RAutomation or autoit - http://www.autoitscript.com/site/
This works for me to launch firebug:
Win 7 & XP:
require 'watir-webdriver'
default = Watir::WebDriver::Firefox::Profile.new
If you are admin on your machine it will be the following... otherwise search and provide path:
default.add_extension("/Users/Administrator/AppData/Roaming/Mozilla/Firefox/Profiles/krqve9uc.firebug/extensions/firebug#software.joehewitt.com.xpi")
b = Watir::Browser.new(:firefox, :profile => default)