You have:
browser = thing('browser')
Did you mean:
browser = thing['browser']
If you're trying to access the browser key, that should take care of it.
سؤال
I'm trying to make testcase using Selenium WebDriver and Ruby. I started learning Ruby a few times ago. I created the testcase:
require "test/unit"
require "selenium-webdriver"
require "yaml"
thing = YAML.load_file('config.yaml')
puts thing.inspect
class Test < Test::Unit::TestCase
def setup
browser = thing('browser')
@driver = Selenium::WebDriver.for browser
@driver.get 'http://google.com'
@driver.manage.delete_all_cookies
end
def teardown
@driver.close
end
def test_page_search
end
end
I decided to use YAML for config file where I will can change and for WebDriver.
config.yaml:
# Set browser (firefox, ie, chrome, opera)
browser: ":firefox"
# Search query
search_query: "ios testing"
But when I'm running the testcase I'm getting the error: "test_yaml.rb:11:in `setup'"
المحلول
You have:
browser = thing('browser')
Did you mean:
browser = thing['browser']
If you're trying to access the browser key, that should take care of it.
نصائح أخرى
Thank you!
I resolved the issue:
require "test/unit"
require "selenium-webdriver"
require "yaml"
class Test < Test::Unit::TestCase
def setup
thing = YAML.load_file('config.yaml')
puts thing.inspect
browser = thing['browser'].to_sym
@driver = Selenium::WebDriver.for browser
@driver.get 'http://google.com'
@driver.manage.delete_all_cookies
end
def teardown
# @driver.close
end
def test_page_search
end
end