I have a Firefox profile that I'd like to launch for testing. It's currently the only profile loaded up on my test machine's copy of Firefox. When I load WebDriver Remote it's not loading my profile. First I tried this:
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => "myprofile")
driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities)
That didn't work and opened up a browser with a blank profile. Then I remember that in PHP WebDriver there was a requirement to copy the profile and Base64 encode it. So I did that:
profile = File.read '/home/me/firefoxprofile.zip.b64'
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities)
But I'm still stuck with a blank profile again. :(
I set a lot of custom preferences and extensions in my profile and would like to load it for each test.
UPDATE:
I also tried adding -FirefoxProfilePath with the webdriver.jar and that also failed to load my profile.
How can I load my custom Firefox profile in WebDriver Remote for testing?
Related
I can't seem to find anything about this, and I'm starting to get upset, because this code used to work:
browser = Watir::Browser.new :firefox, :profile => "Anna"
However, now that code, while it will launch firefox successfully if I use :marionette => true, if I use :profile => "Anna" or even if I do this:
caps = Selenium::WebDriver::Remote::Capabilities.firefox({:profile => profile,:marionette=> true})
browser = Watir::Browser.new :firefox, :desired_capabilities => caps
Watir will still launch firefox and work properly, but it is still using its own profile. I have custom x509 certificates I need to use in that profile (and the site is throwing "This site is not secure" screens at me because it's still in development), so how can I use it? I know there's a way to do it, but I've been Googling for an hour now and have yet to find it. Removing :marionette => true will let the profile load properly, but since Firefox 48 doesn't support the old Firefox driver, I can't make it work.
I am using ruby with watir-webdriver.
when downloading a file with chrome,code is there for setting preferences.
What is the procedure for doing the same with internet explorer
i had tried same preference setting that worked for chrome. But it failed in IE.
require 'watir-webdriver'
Watir.default_timeout = 90
prefs = {
:download => {
:prompt_for_download => false,
:default_directory => "#{custom_download_path}"
}
}
$browser = Watir::Browser.new :chrome, :prefs => prefs
IE version :10+
Platform : windows 7..
You should ask yourself what you are really testing here. Beyond 'is the file available and served correctly to a download request', doing file downloads using different browsers starts to be more of a test of the browser itself than your website/server code. This is the sort of test I'd do on a single browser to verify the download link points to the right file, and call it good. For other browsers maybe just verify that the user can see the download link, and that the URL for the download is correct. Or if you really need to examine the file itself, then get the link address, and just download the file with curl or something similar.
I am currently working on an automation project where I need to use Ruby/Selenium to discover specific http headers returned to the user after authentication to a web app. I am able to automate the web app just fine; however, when I try to use a Chrome extension the browser returns the following error:
The webpage at chrome-extension://[extension address] might be temporarily down or it may have moved permanently to a new web address.
After looking into this, it appears that the Selenium web driver is using a different Chrome profile than my regular Chrome profile. As such, I was wondering if someone knew if there is a way to to tell Selenium to use my regular Chrome profile with the extension loaded or build a new profile and install the extension during runtime.
So far, most of the answers I have found were centralized around Python and Java. Please let me know if I can provide more information.
To launch Chrome with the default profile on Windows:
require 'selenium-webdriver'
switches = ['user-data-dir='+ENV['LOCALAPPDATA']+'\\Google\\Chrome\\User Data']
driver = Selenium::WebDriver.for :chrome, :switches => switches
driver.navigate.to "https://www.google.co.uk"
Or to add an extension to the created profile:
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome,
:desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome({
'chromeOptions' => {
'extensions' => [
Base64.strict_encode64(File.open('C:\\App\\extension.crx', 'rb').read)
]
}
})
driver.navigate.to "https://www.google.co.uk"
I'm working on web-application automation using Ruby 1.9.3p484 and Watir-webdriver (0.8.0) with Firefox 41.0 for Ubuntu.
I want the browser to not load any images. To do that, I try to change the 'permissions.default.image' firefox parameter to 2.
I have tried the following code:
profile = Selenium::WebDriver::Firefox::Profile.new
profile['permissions.default.image'] = 2
browser = Watir::Browser.new(:firefox, :profile => profile)
browser.goto url
But, the browser keep loading the images. In the about:config page, the 'permissions.default.image' is still set to 1.
Any ideas on what could be wrong?
I don't know why, but if I use from_name method in Selenium class init, then you code is working perfectly:
profile = Selenium::WebDriver::Firefox::Profile.from_name "default"
I would like to use my default profile in firefox when watir-webdriver launches a friefox browser, but then I want to switch off javascript in that browser this way:
browser = Watir::Browser.new :ff, :profile => "default"
browser.profile['javascript.enabled']=false
The second reference doesn't work, because the "profile" is not a member of the browser object. How can I access it? Or any other method to switch off javascript either in the default profile or in the running firefox window? I want to do this programmatically, because at the end of my Ruby script I would like to switch it on again.
I think you would do it like this:
profile = Selenium::WebDriver::Firefox::Profile.new
profile['javascript.enabled'] = false
browser = Watir::Browser.new :ff, :profile => profile