Method of login in Ruby

Asked

Viewed 170 times

0

I’m trying to log in with Ruby, but is showing the error

undefined local variable or method `login' for #<Object:0x00000000059ccea8> (NameError)

I rode the class:

class  Login <SitePrism::Page 
    element :username_fild, "input[placeholder='Username']"
    element :password_fild, "input[placeholder='Password']"
    element :Login_buton,   "input[title='Log In']"

    def Login (nome, senha)
        username_fild.set(nome)
        password_fild.set(nome)
        Login_button.click
    end 

end

and passed the variable:

Dado("que esteja na tela de cadastro do SuiteCRM") do
    Home.new.load
    @login = login.new
    @login.load
    @login.login("will","will")

  end

when run generates error:

undefined local variable or method `login' for #<Object:0x00000000059ccea8> (NameError)

Can anyone help to solve this problem?

1 answer

2

Before you start, remember to always follow the guidelines and language conventions, especially when using the Ruby on Rails framework, which is known for the design paradigm Convention over Configuration. Names of methods always in snake_case_minusculo and classes/modules in PascalCase.

Let’s see the error message:

undefined local variable or method `login' for #<Object:0x00000000059ccea8> (NameError)

That means you tried to use .login in an object, of the type Object, that does not have this method. This generates a NameError. In your code, you can see that you called .login, where it should be .Login, since you defined it that way.

And when you charge the class Login, must be Login.new and not login.new.

Remember the conventions!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.