First time messing with Watir.
browser = Watir::Browser.new
browser.goto 'google.com'
My firefox window pops up and stays stuck on a blank page. When I end the script in the command line, I get:
...ruby-1.9.3-p194/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/socket_poller.rb:95:insleep': Interrupt`
I've do have the selenium-webdriver gem (2.29) installed. My firefox version is 19.
I do not think selenium-webdriver supports Firefox 19. Try with Firefox 18.
Related
Question:
For my Test Automation Suite I would like to know how to configure/setup my portable Chrome to run instead of the local installed Chrome.
Reason:
There is an issue with the application I'm trying to test and Chrome Version 55. Issue: Certain buttons are since this version not clickable and I want to bypass this for the time being by using an older Chrome version.
I use Ruby version 2.3.0p0 (2015-12-25 revision 53290)
And LapisLazuli as described on www.testautomation.info
The setup itself is working. The answer might be simple, but I did not manage to get this running in this combination.
I found information about selenium/Java, but I have no idea how to get that to work with my setup.
Selenium not starting portable chrome but local installation
I also found this website: https://leanpub.com/watirbook/read
And here they mentioned the following:
3 > require "selenium-webdriver"
4 => true
5
6 > Selenium::WebDriver::Chrome.path =
7 'C:\chrome\chrome.exe'
8 => "C:\\chrome\\chrome.exe"
So I tried that in irb and this worked
require 'lapis_lazuli'
include LapisLazuli
Selenium::WebDriver::Chrome.path = 'C:\chrome_portable_v53\chrome.exe'
browser :chrome
The portable chrome version was started. Now I only need to know how to place this in my env.rb file (I assume), which looks currently like this:
require 'lapis_lazuli'
require 'lapis_lazuli/cucumber'
LapisLazuli::WorldModule::Config.config_file = "config/config.yml"
World(LapisLazuli)
I think the following is answering the question. I've added require selenium-webdriver and that Chrome.path to the env.rb and this seems to work.
require 'lapis_lazuli'
require 'lapis_lazuli/cucumber'
require 'selenium-webdriver'
Selenium::WebDriver::Chrome.path = 'C:\chrome_portable_v53\chrome.exe'
LapisLazuli::WorldModule::Config.config_file = "config/config.yml"
World(LapisLazuli)
I ran a bundle update yesterday night and selenium-webdriver got updated to the latest version.
My watir-webdriver tests pointed to firefox are now broken.
The error message said to add geckodriver to the path. On my mac, I copied geckodriver to the /usr/bin and ran the tests again.
This is the error I am getting now
unable to connect to Mozilla geckodriver 127.0.0.1:4444 (Selenium::WebDriver::Error::WebDriverError)
The watir-webdriver documentation does not seem to be updated on how to do this?
Did anyone manage to fix this
There is no extra documentation because there is nothing extra to do with Watir. It's finding the geckodriver file , but can't run it. Check to make sure it is executable on your system.
If your test not only just stick to firefox, you can use chromedriver instead of geckodriver, which is much easy, as far as my experience goes.
1, Add gem watir to your gemfile.
2, Download file on this page https://sites.google.com/a/chromium.org/chromedriver/downloads, and copy chromedriver to /usr/bin path.
3, And then just run it:
browser = Watir::Browser.start(url)
html = Nokogiri::HTML.parse(browser.html)
browser.close
4, Also, you can use headless to start a virtual X screen to hide browser windows like this:
headless = Headless.new
headless.start
browser = Watir::Browser.start(url)
html = Nokogiri::HTML.parse(browser.html)
browser.close
headless.destroy
When I start a script with Selenium-Webdriver, the Firefox window that I expect to open never opens. This code used to work, but no longer does:
require 'selenium-webdriver'
p "DEFINING `driver`"
driver = Selenium::WebDriver.for :firefox
p "OPENING GOOGLE"
driver.navigate.to "http://google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Selenium Tutorials"
element.submit
driver.quit
When I run it, "DEFINING `driver`" prints to the console, but the script just hangs there.
The only major thing I did in the past 48 hours was run a virus scan.
You should update your Selenium-Webdriver gem to version 2.45.0
I have just finished setting up the latest versions of Ruby (Ruby 2.0.0-p451 (x64)) and Watir. I have downloaded both the selenium web driver gem and the watir webdriver gem, both installed successfully. I then got the Ruby dev kit, installed that and it installed fine. Lastly, I got the latest version (2.9) of chromedriver.exe and placed it in the bin directory for ruby.
I can start Chrome from a Watir script but I can't navigate to any URL. When Chrome opens a new instance it has one tab and in the URL all it says is "data:,", the page is completely blank. I have used examples and this one works with Firefox but not Chrome
require 'watir-webdriver'
b = Watir::Browser.new :chrome
b.goto 'bit.ly/watir-webdriver-demo'
b.text_field(:id => 'entry_0').set 'your name'
b.select_list(:id => 'entry_1').select 'Ruby'
b.select_list(:id => 'entry_1').selected? 'Ruby'
b.button(:name => 'submit').click
b.text.include? 'Thank you'
(that example came from http://watirwebdriver.com/)
If I remove ":chrome" from the end of the second line, Firefox opens and navigates to the URL as I'd expect, but can't get that to work in Chrome.
If I use the selenium-webdriver with Chrome I get the exact same result: Chrome opens, it has "data:," in the URL and doesn't navigate to the URL in the script.
I also tried this in the Ruby 1.9.3-p545 version of Ruby and I get the exact same result, so I uninstalled that and am now using the 2.0.0 version of Ruby.
How can I get my script to open chrome and navigate to a URL?
I am new to watir. I am trying to create new ie window with
browser = Watir::Browser.new
but it gives error message like
`user_is_bewildered': Error in the default values: :browser's value must be one of 'ie', 'firefox', or 'safari', and '' doesn't look right. (StandardError)
I donno how to set default browser. Can some one help me? There is a another thread here. But I am not able to understand what i need to do in ffi.
Thanks
If this is the original Watir gem, then the following is how I used to launch it:
require 'rubygems'
require 'watir'
Watir::Browser.default = "firefox"
browser = Watir::Browser.new
# Whatever you want to do in watir
IamChuckB's answer may be a more efficient way of doing this, but having not used it, I'm not sure.
You need to tell it which browser to open. Try this:
browser = Watir::Browser.new :ff
I haven't played around with watir since my last job so I had to look this up. As I last recall, WATIR was not entirely integrated with FireWATIR (the Firefox based variant). It's good to see that the two have apparently been reconciled in the meantime.
Taken from Watir in Five Minutes on Zeljko Filipin's github, BTW.
To install devkit,
create a folder in the ruby directory called devkit
get the devkit from here
unpack it into the devkit directory created in step 1
add c:\ruby193\devkit\bin;c:\ruby193\devkit\wming\bin to your path, of course adjusting for your ruby install directory
now open a command prompt to install the gem again
c:\> gem install watir
The issue is resolved. Thanx for the the inputs. The issue was with wrong nokorigi gem installation, initially i installed x86-mswin32-60, i uninstalled it and tried with x86-mingw32, it solved.