Sha256: cdc1163fb0141917876aa0d8ae0d1cbf6880951e3127480898a22595b798e5b3

Contents?: true

Size: 1.8 KB

Versions: 31

Compression:

Stored size: 1.8 KB

Contents

# unit tests for iedialog.dll and customized win32ole.so

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
require 'unittests/setup'
require 'Win32API'

class TC_IEDialog < Test::Unit::TestCase
  include Watir 

  # this will find the IEDialog.dll file in its build location
  @@iedialog_file = (File.expand_path(File.dirname(__FILE__)) + "/../../lib/watir/IEDialog/Release/IEDialog.dll").gsub('/', '\\')
  
  # commented out because it currently requires a manual click
  # a better idea would be to automate the click...
  def xtest_connect_to_iedialog 
    # make sure we can connect to the IEDialog.dll
    fnShowString = Win32API.new(@@iedialog_file, 'ShowString', ['p'], 'v')
    fnShowString.call("from ruby!") # blocks
  end

  def test_find_window   
    goto_page "pass.html"
    fnFindWindow = Win32API.new('user32.dll', 'FindWindow', ['p', 'p'], 'l')
    hwnd = fnFindWindow.call(nil, "Pass Page - Microsoft Internet Explorer")
    assert(hwnd != 0)
  end

  def test_all    
    goto_page "pass.html"

    fnFindWindow = Win32API.new('user32.dll', 'FindWindow', ['p', 'p'], 'l')
    hwnd = fnFindWindow.call(nil, "Pass Page - Microsoft Internet Explorer")

    fnGetUnknown = Win32API.new(@@iedialog_file, 'GetUnknown', ['l', 'p'], 'v')
    intPointer = " " * 4 # will contain the int value of the IUnknown*
    fnGetUnknown.call(hwnd, intPointer)
    
    intArray = intPointer.unpack('L')
    intUnknown = intArray.first

    assert(intUnknown > 0)
    
    htmlDoc = nil
    assert_nothing_raised{htmlDoc = WIN32OLE.connect_unknown(intUnknown)}
    scriptEngine = htmlDoc.Script
    
    # now we get the HTML DOM object!
    doc2 = scriptEngine.document
    body = doc2.body
    assert_match(/^PASS/, body.innerHTML.strip)    
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
watir-3.0.0.rc2 unittests/windows/iedialog_test.rb
watir-3.0.0.rc1 unittests/windows/iedialog_test.rb
watir-2.0.4 unittests/windows/iedialog_test.rb
watir-2.0.3 unittests/windows/iedialog_test.rb
watir-2.0.2 unittests/windows/iedialog_test.rb
watir-2.0.2.rc1 unittests/windows/iedialog_test.rb
watir-2.0.1 unittests/windows/iedialog_test.rb
watir-2.0.0 unittests/windows/iedialog_test.rb
watir-2.0.0.rc3 unittests/windows/iedialog_test.rb
watir-2.0.0.rc2 unittests/windows/iedialog_test.rb
watir-1.9.2 unittests/windows/iedialog_test.rb
watir-1.9.2.rc1 unittests/windows/iedialog_test.rb
watir-1.9.1 unittests/windows/iedialog_test.rb
watir-1.9.1.rc1 unittests/windows/iedialog_test.rb
watir-1.9.0 unittests/windows/iedialog_test.rb
watir-1.9.0.rc7 unittests/windows/iedialog_test.rb
watir-1.9.0.rc6 unittests/windows/iedialog_test.rb
watir-1.9.0.rc5 unittests/windows/iedialog_test.rb
watir-1.9.0.rc4 unittests/windows/iedialog_test.rb
watir-1.9.0.rc3 unittests/windows/iedialog_test.rb