[Wtr-general] how to properly use the snippet function?

2007-06-13 Thread reinier
I am trying to get rid of all cookies via a function.
On this forum I found the Snippet thingy.
http://rubyforge.org/snippet/detail.php?type=snippetid=26
So I included that code in my script and trying to use it, but I can't figure 
out how.

this is the code:
[code]
DeleteUrlCacheEntry = Win32API.new(wininet, DeleteUrlCacheEntry, ['P'], 'V')
[/code]

So what function should be called to delete all the cookies?
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] how to delete cookies (trying now with snippet but this is quite unclear)

2007-06-13 Thread reinier
got it working myself.
by calling the delete_cache and including the file mentioned below (got that 
from this forum somewhere)
[code]
#!/bin/ruby
#
#
#
#
#
# set TEMPIF=%USERPROFILE%\Local Settings\Temporary Internet Files
# %TEMPIF%\Content.IE5\Index.DAT


require 'Win32API'

#
#
# HashMethods = a Hash that can be accessed with methods
#   e.g.h = MethodHash.new
#   h['street'] = 'Broadway'
#   h.street= 'Broadway'
#   puts h.street  === Broadway

require 'delegate'

class MethodHash  SimpleDelegator
def initialize h = {}
super h
end

def method_missing(method_name, *args)
name = method_name.to_s
if name.ends_with?('=')
self[ name.chop ] = args[0]
else
self[ name ]
end
end
end


class String
def ends_with?(substr)
len = substr.length
self.reverse() [0 .. len-1].reverse == substr
end

def starts_with?(substr)
len = substr.length
self[0 .. len-1] == substr
end

alias start_with?  starts_with?
alias begin_with?  starts_with?
alias begins_with? starts_with?
alias end_with?ends_with?

# String each() operator reads line-by-line
# These functions return characters
def each_char
self.each_byte{|x| yield x.chr }
end
def collect_char
r = []
self.each_byte{|x| r  x.chr }
r
end
end


=begin

// Windows System calls needed to clear cache.
//

BOOL DeleteUrlCacheEntry(
  LPCTSTR lpszUrlName
);

HANDLE FindFirstUrlCacheEntry(
  LPCTSTR lpszUrlSearchPattern,
  LPINTERNET_CACHE_ENTRY_INFO lpFirstCacheEntryInfo,
  LPDWORD lpdwFirstCacheEntryInfoBufferSize
);

BOOL FindNextUrlCacheEntry(
  HANDLE hEnumHandle,
  LPINTERNET_CACHE_ENTRY_INFO lpNextCacheEntryInfo,
  LPWORD lpdwNextCacheEntryInfoBufferSize
);

BOOL FindCloseUrlCache(
IN HANDLE hEnumHandle
);


typedef struct _INTERNET_CACHE_ENTRY_INFO {
DWORD dwStructSize;
LPTSTR lpszSourceUrlName;
LPTSTR lpszLocalFileName;
DWORD CacheEntryType;
DWORD dwUseCount;
DWORD dwHitRate;
DWORD dwSizeLow;
DWORD dwSizeHigh;
FILETIME LastModifiedTime;
FILETIME ExpireTime;
FILETIME LastAccessTime;
FILETIME LastSyncTime;
LPBYTE lpHeaderInfo;
DWORD dwHeaderInfoSize;
LPTSTR lpszFileExtension;
union {
DWORD dwReserved;
DWORD dwExemptDelta;
}
} INTERNET_CACHE_ENTRY_INFO, *LPINTERNET_CACHE_ENTRY_INFO;


=end




def delete_cache
w = get_api('wininet',FUNCS)
i = 0

info,infosize = get_first_info(w)
cache = w.FindFirstUrlCacheEntry.Call(nil,info,infosize)
if cache != 0
begin
len, source_file_ptr, local_file_ptr = info.unpack 'LLL'
w.DeleteUrlCacheEntry.Call(source_file_ptr)
i += 1
info,infosize = get_next_info( w, cache )
end while w.FindNextUrlCacheEntry.Call(cache, info, infosize) != 0
end
w.FindCloseUrlCache.Call(cache)
i
end

def get_first_info(api)
sizenum = [0,0].pack('L*')
buf =  [1024,0].pack('L*').ljust(1024)
r = api.FindFirstUrlCacheEntry.Call(nil,nil,sizenum)
n = sizenum.unpack('L')[0]
info = sizenum.ljust(n)
[info,sizenum]
end

def get_next_info(api, handle)
sizenum = [0,0].pack('L*')
buf =  [1024,0].pack('L*').ljust(1024)
r = api.FindNextUrlCacheEntry.Call(handle,nil,sizenum)
n = sizenum.unpack('L')[0]
info = sizenum.ljust(n)
[info,sizenum]
end


#
# Win32 API used in this file is listed here.
# Each system call can be instatiated like this
#DeleteUrlCacheEntry = Win32API.new(wininet, DeleteUrlCacheEntry, 
['P'], 'V')
# Instead, the functions are defined dynamically from this list:
#
FUNCS = {
'FindFirstUrlCacheEntry' = ['ppp','n'],
'FindNextUrlCacheEntry'  = ['npp','n'],
'DeleteUrlCacheEntry'= ['n',  'n'],
'FindCloseUrlCache'  = ['n',  'n']
}

#
# get_api returns a hash with Win32 API system calls
# Usage:
# api = get_api('Kernel32', {'GetLastError'=['V', 'N'],...})
#
def get_api(library, function_hash)
f = MethodHash.new
function_hash.each{|funcname,types|
in_types = types[0].collect_char{|x| x}
out_type = types[1]
f[funcname] = Win32API.new(library, funcname, in_types, out_type)
}
f
end


def getLastError
f = Win32API.new('Kernel32', 'GetLastError', ['V'], 'N')
f.call
end


if __FILE__ == $0
n = main
# print Deleted #{n} items\n
end


[/code]
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Link description from file

2007-06-08 Thread reinier
I have the same issue.
Anyone knows how to handle regular expression retrieved from a file? (so they 
are a string when used)
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] odd thing on comparing strings

2007-06-07 Thread reinier
Something odd here, or something foolish I simply miss;)

[CODE]
strTemp=browser.getEditbox(guiMap.getWindow('login').getObject('Login 
Editbox','','').getFysicalDescription())
strTemp2='[EMAIL PROTECTED]'
if (strTemp.eql?(strTemp2))
  puts('strings match')
else
  puts('string does not match')
end
if (browser.getEditbox(guiMap.getWindow('login').getObject('Login 
Editbox','','').getFysicalDescription().eql?('[EMAIL PROTECTED]')))
  puts('TESTCHECK: PASS correct value found in editbox')
else
  puts('TESTCHECK: FAIL incorrect value found in editbox')
end
[/CODE]

The first if statement returns strings match. which is correct, as they indeed 
do  match.
However the 2nd if statement returns the following error: 
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:1104:in 
`locate_input_element': undefined method `m
atches' for false:FalseClass (NoMethodError)
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:1091:in 
`each'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:1091:in 
`locate_input_element'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:3717:in 
`locate'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:2412:in 
`assert_exists'
from (eval):2:in `getContents'
from ./Classes/CLBrowser.class.rb:338:in `getEditbox'

The odd thing about it, is that ther same values are compared with eachother.
Any ideas?
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] length not recognized for array within a class

2007-06-04 Thread reinier
thanks, that was the solution
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] Newbie problem with submitting a login

2006-08-28 Thread Reinier Mostert



Hi 
all,

First off, I want to 
apologize for the uge chunk of HTML, but I can't seem to figure out how to 
submit this correctly.

I've tried a submit 
on the form, but I think the _javascript_ needs to run to enable the login. 
I've tried to get to the login image (there's no button), but I can't get past 
the DIV element (not sure how to get the children of a DIV). Is there 
anyone that can help? I can give more info if 
neccessary.

Thanks in 
advance
reinier

 cut here 
---
body class="login" text="#00" IE:clientCaps ID="oClientCaps" /

div name="bglayer" id="bglayer" 
 form name="login" target="_top" 
action="" method="POST" 
 
input type="hidden" name="LOGIN" input 
type="hidden" name="action" 
table border=0 cellspacing=0 
cellpadding=0 
tr 
td 
img src="" 
id="loginBackground"/ 
/td 
/tr 
/table

 !-- 
Entry Area -- div 
name="entryArea" id="entryArea" 
class="entryArea" 
table height="110" width="152" border=0 cellspacing=0 
cellpadding=0 
tr 
td align="right" colspan="1"User 
Name/td 
tdnbsp;/td 
tdinput type="Text" name="usr" id="usr" style="height : 20px; 
width:68px; font-size : 10px" value="" 
maxlength="25"/td 
/tr 
tr 
td align="right" 
colspan="1"Company/td 
tdnbsp;/td 
tdinput type="Text" name="cpny" id="cpny" style="height : 20px; 
width:68px; font-size : 10px" value="" 
maxlength="32"/td 
/tr 
tr 
td 
align="right"Password/td 
tdnbsp;/td 
tdinput type="Password" style="height : 20px; width:68px; font-size 
: 9px" name="pwd" 
/td 
/tr 
tr 
td align="center" 
colspan=3 
img src="" 
id="loginBtn"/ 
/td/tr 
TR 
td align="center" 
colspan=3 
table 
tr  
 
tdimg src="" 
//td 
td style="font-size:9px"I forgot my 
password/td 
/tr 
/table 
/td/tr 
/table 
div name="loginBtn" id="logInBtn" 
class="loginBtnArea" 
table width= 
"125" 
tr align="center"  
 
tdimg src="" 
//td 
td 
align="left"Login/td 
/tr 
/table 
/div /div cut here 
---
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general