A
aidy
Hi,
I am trying to write a 'keyword-driven test automation framework' in
Ruby.
Using a case statement
<snip>
def field(name, args)
case name
when 'username'
name='login'
when 'password'
name='password'
end
return $ie.text_fieldname, name).set(args)
end
def button(name)
case name
when 'login'
name = 'Login'
end
return $ie.buttonvalue, name).click
end
<snip>
Calling code
<snip>
field 'username', '(e-mail address removed)'
field 'password', 'password123'
button 'login'
<snip>
I don't like it because
1. It is procedural
2. Lengthy switch statements may affect performance
Could anyone suggest a way using, collections or symbols or something
else?
Thanks
aidy
I am trying to write a 'keyword-driven test automation framework' in
Ruby.
Using a case statement
<snip>
def field(name, args)
case name
when 'username'
name='login'
when 'password'
name='password'
end
return $ie.text_fieldname, name).set(args)
end
def button(name)
case name
when 'login'
name = 'Login'
end
return $ie.buttonvalue, name).click
end
<snip>
Calling code
<snip>
field 'username', '(e-mail address removed)'
field 'password', 'password123'
button 'login'
<snip>
I don't like it because
1. It is procedural
2. Lengthy switch statements may affect performance
Could anyone suggest a way using, collections or symbols or something
else?
Thanks
aidy