Class: SeleniumDsl

Inherits:
Object
  • Object
show all
Extended by:
Commands, Engines, Modules
Defined in:
lib/selenium_dsl.rb,
lib/selenium_dsl/macros.rb,
lib/selenium_dsl/engines.rb,
lib/selenium_dsl/modules.rb,
lib/selenium_dsl/commands.rb

Defined Under Namespace

Modules: Commands, Engines, Modules

Class Method Summary collapse

Methods included from Modules

in_modules?, modules, parse_fnc, parse_mod

Methods included from Engines

engines, in_engines?, parse_eng

Methods included from Commands

commands, find_element, find_elements, in_commands?, parse_cmd, parse_mcr

Class Method Details

.initObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/selenium_dsl.rb', line 17

def init
  nodes    = /^(\>*([\-\w]*(\.[.\[\]\-\d\w]+|[#:][\-\d\w]+)|\w+(\[\w+\=[\d\w"]+\])*)|\/[\w@"=\[\]]+)(\[\d+\])*/
  action   = /^[~@]\w+(\:\w+)*/
  @driver  = nil
  @nodes   = nil
  @return  = nil
  @mock    = false 
  @code    = {}
  @path    = '~'
  @opt     = []
  @r_eng   = [/^(debug|chrome|firefox|phantomjs|remote|resize|visit|wait|quit|if|screenshot|sleep)/] #mock|debug|
  @r_mcr   = [/^\$[\-\w]+ *\=/,/^\$[\-\w]+[^\=]/]
  @r_cmd   = [nodes, action]
  @r_mod   = [/^(def +|end)/]
  @r_fnc   = [/^ *\w+.*/]
end

.match_line(rgx, str, id = '') ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/selenium_dsl.rb', line 34

def match_line(rgx,str,id='')
  str2 = str
  arr = rgx.collect do |r|
    rtn = []
    while (x=str[r]) 
      str = str[x.length,255].strip
      rtn << x.strip
    end
    rtn
  end << str
  arr
end

.parser(codes, opt = '') ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/selenium_dsl.rb', line 47

def parser(codes, opt='')
  init if !@driver
  @opt  = opt
  codes = codes.split(/\n/)
  puts "OPT: #{@opt}" if opt
  @code[@path] = 
  {
    :macro => {},
    :code  => codes,
    :vars  => {},
    :line  => 0  
  }
  
  while (line = _line_)
    stx = parse_mod(line)
    stx = parse_mcr(line) if !stx
    stx = parse_eng(line) if !stx
    stx = parse_cmd(line) if !stx
    stx = parse_fnc(line) if !stx
  end
  @driver.quit if opt_q && @driver
  print "\n"
end