Skip to content

Instantly share code, notes, and snippets.

# takes a screenshot of the foreground
width, height, bmp = Win32::Screenshot.foreground
# takes a screenshot of the desktop
width, height, bmp = Win32::Screenshot.desktop
# takes a screenshot of the window having "Firefox" as part of it's title
width, height, bmp = Win32::Screenshot.window(/Firefox/)
# saves the last bitmap to the file
C:\Users\jarmo>set RAUTOMATION_ADAPTER=autoit
ie_autoit = RAutomation::Window.new :title => /internet explorer/i
=> #<RAutomation::Window:0x480c000 @window=#<RAutomation::Adapter::Autoit::Window:0x480bf28 @hwnd=nil, @locators="[regexptitle:(?i-mx:internet explorer)]", @locator_text=nil>, @adapter=:autoit>
ie_autoit.hwnd
=> 18155218
ie_ffi = RAutomation::Window.new :hwnd => 18155218, :adapter => :ffi
=> #<RAutomation::Window:0x59fd2d0 @window=#<RAutomation::Adapter::Ffi::Window:0x59b4610 @hwnd=18155218, @locators= :hwnd=>18155218}>, @adapter=:ffi>
ie_ffi.hwnd
=> 18155218
require "rubygems"
require "watir"
Watir::Browser.default = "firefox"
b = Watir::Browser.new
b.goto "google.com"
1)
Errno::ENOTSOCK in 'WebDriver::TargetLocator should switch to a window'
An operation was attempted on something that is not a socket.
C:/Users/jarmo/Desktop/minu/projects/Ruby/selenium-read-only/build/rb/lib/selenium/webdriver/chrome/command_executor.rb:60:in `accept'
C:/Users/jarmo/Desktop/minu/projects/Ruby/selenium-read-only/build/rb/lib/selenium/webdriver/chrome/command_executor.rb:60:in `start_run_loop'
C:/Users/jarmo/Desktop/minu/projects/Ruby/selenium-read-only/build/rb/lib/selenium/webdriver/chrome/command_executor.rb:18:in `block in initialize'
2)
IOError in 'WebDriver::TargetLocator should switch to a window and back when given a block'
closed stream
1)
Errno::ENOTSOCK in 'WebDriver::TargetLocator should switch to a window'
An operation was attempted on something that is not a socket.
C:/Users/jarmo/Desktop/minu/projects/Ruby/selenium-read-only/build/rb/lib/selenium/webdriver/chrome/command_executor.rb:60:in `accept'
C:/Users/jarmo/Desktop/minu/projects/Ruby/selenium-read-only/build/rb/lib/selenium/webdriver/chrome/command_executor.rb:60:in `start_run_loop'
C:/Users/jarmo/Desktop/minu/projects/Ruby/selenium-read-only/build/rb/lib/selenium/webdriver/chrome/command_executor.rb:18:in `block in initialize'
2)
IOError in 'WebDriver::TargetLocator should switch to a window and back when given a block'
closed stream
--require
environment.rb
C:\Users\jarmo\Desktop\minu\projects\Ruby\selenium-read-only>git svn rebase
Index mismatch: e127137725ae686ae519995e609904631562a06c != 4505082dc8b370e78cb32378484ce87f951b7152
rereading d8c4bf81ba88e8b7df5b1f52916e376f8b00a29d
M Rakefile
M ide/src/extension/locale/ja-JP/selenium-ide.dtd
M ide/src/extension/locale/ja-JP/selenium-ide.properties
M ide/src/extension/locale/pt-BR/selenium-ide.dtd
M ide/src/extension/locale/pt-BR/selenium-ide.properties
M ide/src/extension/locale/en-US/selenium-ide.dtd
M ide/src/extension/locale/en-US/selenium-ide.properties
>>prompt("enter!")
"info"
>>prompt("cancel!")
null
>>confirm("yes!")
true
>>confirm("no!")
false
# watir/element.rb
def click_no_wait
assert_enabled
highlight(:set)
object = "#{self.class}.new(self, :unique_number, #{self.unique_number})"
@page_container.eval_in_spawned_process(object + ".click!")
highlight(:clear)
end
C:\projects\for-blog\lib>spec watir_with_rspec.rb
.F
1)
'Google has word 'Bing' as it's title' FAILED
expected: "Bing",
got: "Google" (using ==)
C:/projects/for-blog/lib/watir_with_rspec.rb:16
Finished in 23.969 seconds