Error trying to run Selenium with IE 8 - ruby

I am getting the following error:
Unable to find standalone executable. Please download the IEDriverServer from http://code.google.com/p/selenium/downloads/list and place the executable on your PATH. (Selenium::WebDriver::Error::WebDriverError)
I have read the wiki on PATH but I'm still confused as to what this means for me. Where do I place the .exe in the scheme of my project?
wiki: http://en.wikipedia.org/wiki/PATH_(variable)
I am using selenium and cucumber to test a website
Here is my code
require 'selenium-webdriver'
#driver = Selenium::WebDriver.for :ie

You need to download the IE driver from the downloads page, then include the path to the file (example : C:\Users\megaxelize\Desktop)i.e. the location where you have downloaded the IEdriver, in your environment path.
This is the way to update your env path vairable
Path specifies the directories in which executable programs are located on the machine that can be started without knowing and typing the whole path to the file on the command line.
More info here

You need IEDriverServer, which you can download from seleniumhq.org.Once your download is complete either you can mention the path to IEDriverServer.exe against your path variables (for which you need Admin access) or you can provide path to IEDriver.exe at command prompt using
java -Dwebdriver.ie.driver=E:\selinum\IEDriverServer_Win32_2.32.3\IEDriverserver.exe
or U can set system property in your script if you use Java using :
File file = new File("E:\\selinum\\IEDriverServer_Win32_2.31.0\\IEDriverServer.exe");//if this is the location of your IEDriverServer.exe
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());

Download IEDriverserver
Extract the zipped folders and add them in Environment Variables path.
My Computer > (right click) properties > Advanced system settings > Environment Variables
Click path under system variables and choose Edit.
Paste the Driver location.
#driver = Selenium::WebDriver.for :ie
or|
#driver = Selenium::WebDriver.for :internet_explorer

Related

Wrong download directory for Selenium Firefox Geckodriver

I've been trying to get Selenium to download a file to a specific folder, but to no avail.
Here is my current driver setup with lots of simultaneous attempts to influence the download directory:
#<Selenium::WebDriver::Firefox::Options:0x00007f94374c0bd0 #debugger_address=nil,
#options={
:browser_name=>"firefox",
:args=>[],
:prefs=>{
"download.folderList"=>2,
"download.dir"=>"./downloads",
"download.directory_upgrade"=>true,
"download.prompt_for_download"=>false,
"download.default_directory"=>"./downloads",
"plugins.plugins_disabled"=>"Chrome PDF Viewer",
"browser.helperApps.neverAsk.saveToDisk"=>"application/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/csv"
}
},
#profile=#<Selenium::WebDriver::Firefox::Profile:0x00007f94374c0e28 #model=nil,
#additional_prefs={
"browser.download.folderList"=>2,
"browser.download.manager.showWhenStarting"=>false,
"browser.download.downloadDir"=>"./downloads",
"browser.download.dir"=>"./downloads",
"browser.download.directory_upgrade"=>true,
"browser.download.prompt_for_download"=>false,
"browser.download.default_directory"=>"./downloads"
}, #extensions={}>>
I have tried:
Download directory (I'm using Mac):
/lib/downloads
downloads
./downloads
Lots of combinations of the above attempts to set the download directory.
I went through the selenium-webdriver docs and Mozilla Webdriver docs, but I cannot find references to set the download directory.
Try this and let me know whether it works.
profile = Selenium::WebDriver::Firefox::Profile.new(ENV['APPDATA'] + '\Mozilla\Firefox\Profiles\3deyh6ub.default-release')
profile['browser.download.dir'] = custom_download_dir
profile['browser.download.folderList'] = 2
options = Selenium::WebDriver::Firefox::Options.new(profile: profile)
driver = Selenium::WebDriver.for :firefox, options: options
and check out this path Mozilla\Firefox\Profiles\3deyh6ub.default-release and see what's the folder name and give the folder name accordingly and it will work.
The custom directory path has to be absolute, formed as shown:
On Mac, ~Downloads folder would be /Users/[me]/Downloads.
In Rails, say you want to put the downloads in lib/custom_downloads, the directory specified should be Dir.pwd + '/lib/custom_downloads'.
The code that worked for me:
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = Dir.pwd + '/forecastsdir'
profile['browser.helperApps.neverAsk.saveToDisk'] = ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel')
options = Selenium::WebDriver::Firefox::Options.new(profile: profile, args: ['-headless'])
driver = Selenium::WebDriver.for :firefox, options: options
Many thanks to #Rajagopalan (+1) for assistance.

How do I change the default version of Firefox using Selenium webdriver with Ruby?

I was able to use the following code to change the Firefox version I am using to 33.1 successfully. But how can I make the current version the default without having to add this additional code to each script?
path='C:\Program Files (x86)\Mozilla Firefox\firefox.exe'
Selenium::WebDriver::Firefox.path = path
driver = Selenium::WebDriver.for :firefox
I have converted Selenium IDE scripts to WebDriver using Ruby and it always defaults to Firefox 11. My computer's default version of Firefox is 33.1 and my current WebDriver version for Ruby is 2.44.
Point the webdriver firefix profile to existing default profile as below:
default_profile = Selenium::WebDriver::Firefox::Profile.from_name "default"
default_profile.native_events = true
driver = Selenium::WebDriver.for(:firefox, :profile => default_profile)
Refer here for more details.
In case if you are using windows follow steps to set default profile, you can also search for equivalent process in case of any other OS, Following solution is purely non-programatic.
1) click start
2) type "run"
3) type "firefox.exe -p"
4) Press "ok"
then following dialog appears, select any Firefox profile according to your needs.
You can also create and delete profiles, and also load them by referring to their path or name.

How do I run my selenium ruby scripts on different browsers?

I have written my script specifically for FF. Now I wish to run that same script on Chrome as well as IE. Also I want to run my tests in following order :
Open browser1.
Run script on that browser.
Close browser1.
Open browser2.
Run script on that browser.
Close browser2.
Please help.
In order to run your tests on :
1.Chrome : you will need to install latest Chrome driver, unzip it and paste its path in the environment variables.
2.IE : you will need to install IEDriver server unzip it and paste its path in the environment variables and enable protected mode for each zone in following way (Internet options->security tab->enable protected mode checkbox).
For running your tests as per the way you mentioned, not sure what framework you're using or whatever, but you can do this with a loop. You can do the following :
def all_browsers
browsers = [:firefox,:chrome,:ie].each do |br|
$driver = Selenium::WebDriver.for br
$driver.manage.window.maximize
$driver.navigate.to("http://google.com")
end
$driver.quit
end

browsermob-proxy-rb wit watir/selenium

I'm searching to figure out what to put on the the next line of code on https://github.com/jarib/browsermob-proxy-rb:
server = BrowserMob::Proxy::Server.new("/path/to/download/browsermob-proxy")
so what to put on /path/to/download/browsermob-proxy and where is it or how to download and put it there? I'm on windows xp trying to setup and make har file.
path can be found in folder of gems and in my case it is:
'C:/Ruby193/lib/ruby/gems/1.9.1/gems/browsermob-proxy-0.1.3/lib/browsermob-proxy.rb'
The Ruby Browsermob gem is a wrapper to control the proxy written in Java from your Ruby script.
You need to provide the path to the proxy executable, so that the gem can start the server for you.
Example:
browsermob_bin = "/path/to/browsermob-proxy-2.1.4/bin/browsermob-proxy"
server = BrowserMob::Proxy::Server.new browsermob_bin
server.start
You can dowload the proxy binary from here: https://github.com/lightbody/browsermob-proxy/releases

How to add IEDriverServer to PATH

I am elaborating on a question I asked yesterday about PATHs. I am trying to run my selenium tests in IE 8. I have downloaded the IEDriverServer_x64_2.33.0 and it is located in my downloads folder. I have tried adding this location in the following ways:
Control Panel> System>Advanced> Environment Variables
The path is separated by a semicolon in PATH and CLASSPATH (ex.;C:\Users\username\Downloads\IEDriverServer_x64_2.33.0) Neither of these gets my test to run. Could it be how i'm associating the ie browser? I can not run the driver in cmd.exe so i have assumed it is not this.
env.rb :
require 'selenium-webdriver'
require 'rubygems'
require 'rspec/expectations'
#driver = Selenium::WebDriver.for :ie
Any advice. I hope this is enough information to show my problem.
Also here is the error output:
Unable to find standalone executable. Please download the IEDriverServer from http://code.google.com/p/selenium/downloads/list and place the executable on your PATH. (Selenium::WebDriver::Error::WebDriverError)
Unzip the IEDriver.zip file in any folder, so that folder contains IEDriver file
e.g
you unzipped it in C:\Drivers\
Copy path till that folder. means only C:\Drivers\
Go to My Computer -> Properties -> Advanced Settings -> Environment Variables
Under that in front of PATH paste our path i.e C:\Drivers\ at the end and before that put ;
Apply the changes made
Restart command prompt
You need to unzip the IEdriver zip file first. Then provide C:\Users\megaxelize\Downloads in the path. Path to the IEDriver file is the path of the "folder" in which the IEDriver lies.
UPDATE
For a quick test, just drop the IEDriver (not the zip file) and drop it in `C:\Windows\System32. Then run your tests.

Resources