Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7541243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:50:34+00:00 2026-05-30T07:50:34+00:00

I am new to Ruby and need help in accessing a function which is

  • 0

I am new to Ruby and need help in accessing a function which is present in another file. The scenario is I have 2 files lets say test.rb and functions.rb

in test.rb i have the below code

require 'rubygems'
require 'watir'
require 'win32ole'
require 'erb' 
require 'ostruct' 
require 'C:\functions'
include Watir
U_RL="some url"
browser
if
ie.text.include?"There is a problem with this website's security certificate."
then
ie.link(:id, 'overridelink').click
end

now in the functions.rb file I have the below code

require 'rubygems'
require 'watir'
require 'win32ole'

include Watir

def browser
      ie=IE.new 
      ie.maximize
      ie.goto U_RL
      ie.focus
      ie.bring_to_front
      ie.wait()
end

When I run test.rb, I get the error “Undefined local variable or method ‘ie’ for main:object

I can see that the browser is opened and even the the mentioned url is coming up, but when the security warning page comes up it is not clicking on ie.link(:id, ‘overridelink’).click.

Please let me know how to over come this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:50:35+00:00Added an answer on May 30, 2026 at 7:50 am

    In your definition of the browser method, the scope of ie is local to that method. It can not be accessed outside of it.

    This code needs to be completely refactored, but for now, you could just have browser return the local instance of ie, and set it in test.rb

    functions.rb:

    def browser
          ie=IE.new 
          ie.maximize
          ie.goto U_RL
          ie.focus
          ie.bring_to_front
          ie.wait()
          ie # last value is returned in ruby; can be explicit and do `return ie` as well
    end
    

    test.rb:

    ie = browser
    if ie.text.include?"There is a problem with this website's security certificate."
    then
      ie.link(:id, 'overridelink').click
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty new to database setup in Ruby and need help in setting it
I am new to ruby. I need to receive password as an input through
Helo, I am pretty new to Ruby (using 1.8.6) and need to know whether
I'm re-defining a method in an object in ruby and I need the new
I am new to Ruby on Rails, I have completed the Blog Tutorial .
I'm very newbie in ruby and need your help. I must save a Topic
I am a new Ruby on Rails user and had a question. I have
I am new to ruby on rails. Could you please help me to install
Im very new to programming with ruby on rails. I need to write a
I have a simple Ruby base class where all the methods need to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.