Hi guys i'm doing some automations scripts with Watir and trying to create a ruby class to make it better but i'm having this error:

> 
> examen.rb:6:in 'enterEmail': undefined method 'text\_field' for # (NoMethodError)
> 
> 
> 

This is part of my conflictive code:

```
require 'watir-webdriver'
class LoginPage 
  def enterEmail (email)
    text_field(:user, :id => 'user_email').set email
  end
end

```

The problem that i see is: i did not define the 'text\_field()' method in my class just because is a Watir method... Anyone knows how can i use the watir method in the classes that i create?
['https://Stackoverflow.com/questions/30365008', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3247357/']
`text_field` is an instance method of The `Watir::Browser` class. If you want to use it, you have to call it on an instance of that class.

```
class LoginPage
  def initialize()
    @b = Watir::Browser.new
  end 

  def enterEmail (email)
    @b.text_field(:user, :id => 'user_email').set email
  end
end

```
Both Yossi and Martin have correct answers. But because you're defining a `LoginPage` class, you should probably look into the [page-object](http://github.com/cheezy/page-object) gem. This lets you define a `text_field` almost identical to the code you already have. Your class would look like:

```
class LoginPage
  include PageObject

  text_field(:user, :id => 'user_email')      

  def enter_email(email)
    self.user = email
  end
end

```

And you'd execute it like:

```
login = LoginPage.new(browser)
login.enter_email("my_email@example.com")

```