Module: Capykit::Base::Core

Defined in:
lib/capykit/base/core.rb

Instance Method Summary collapse

Instance Method Details

#a(sym) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/capykit/base/core.rb', line 3

def a(sym)
  gselector(sym)
  if !@selec
    @selec=@pname=='*' ? "a[href*=#{@name[1,99]}]" : @name
  end
  @nodes = all(@selec)
  selec_info('a',sym)
  @value='0' if !@value
  if @value.scan(/[^\d]+/)==[]
    @node = @nodes[@value.to_i]
    puts [' '*28,"@nodes[#{@value}]"].join
  else
    @node = @nodes.select{|x|x.text=~/#{@value}/}[0]
    puts [' '*28,"@nodes.select{|x|x.text=~/#{@value}/}[0]"].join
  end
  @node.click
  self
end

#aselector(xhash = nil) ⇒ Object



82
83
84
85
86
# File 'lib/capykit/base/core.rb', line 82

def aselector(xhash=nil)
  @aselector||={} 
  @aselector  =@aselector.merge xhash if xhash
  @aselector
end

#f(*arg) ⇒ Object

Possible Keys :null, :cancel, :help, :backspace, :tab, :clear, :return, :enter, :shift, :left_shift, :control, :left_control :alt, :left_alt, :pause, :escape, :space:page_up, :page_down, :end, :home, :left, :arrow_left, :up:arrow_up, :right, :arrow_right:down, :arrow_down, :insert, :delete, :semicolon, :equals, :numpad0, :numpad1, :numpad2, :numpad3, :numpad4, :numpad5, :numpad6, :numpad7, :numpad8, :numpad9, :multiply, :add, :separator, :subtract, :decimal, :divide



28
29
30
31
32
33
# File 'lib/capykit/base/core.rb', line 28

def f(*arg)
  arg.each do |sym|
    find_fnode(sym)
  end
  self
end

#v(loc = :l, *oth) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/capykit/base/core.rb', line 35

def v(loc=:l,*oth)
  params=[]
  vsites=[]
  status=" > v "
  ([loc]+oth).each do |sym|
    if sym.class==Symbol
      params<<":#{sym}"
      vsites<<vsite[sym]
    else
      params<<"'#{sym}'"
      vsites<<sym
    end
  end
  location=''
  location=page.current_url.split('/')[0,3].join('/') if vsites[0][0,1]=='/'
  location<<vsites.join
  status<<params.join(',')
  status=[status,' '*25].join[0,25]
  status<<" - v('#{location}')"
  puts status
  visit location 
  self
end

#vsite(xhash = nil) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/capykit/base/core.rb', line 71

def vsite(xhash=nil)
  @vsite||={
    :l => 'http://localhost:3000',
    :f => 'http://facebook.com',
    :g => 'http://google.com',
    :y => 'http://yahoo.com',
    :b => 'http://bing.com'}
  @vsite  =@vsite.merge xhash if xhash
  @vsite
end

#w(sym, new_out = 15) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/capykit/base/core.rb', line 59

def w(sym,new_out=15) 
  gselector(sym)
  @selec=@name if !@selec
  selec_info('w',sym)
  new_out=@value.to_i if @value
  old_out = Capybara.default_wait_time
  Capybara.default_wait_time = new_out
  result=page.has_css?(@selec)
  Capybara.default_wait_time = old_out
  result
end