我可以将alias_method与新对象一起使用并为其提供固定参数吗?

时间:2014-06-19 06:20:23

标签: ruby

我能这样做吗,

但是我遇到了一些关于Selenium的错误

alias_method :select_by ,Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, "time_entry_activity_id")).select_by


[remote server] file:///var/folders/n5/b8s03z3d7ljg5w74qxm_k4500000gn/T/webdriver-profile20140619-17231-9tb59x/extensions/fxdriver@googlecode.com/components/driver_component.js:9470:7:in `FirefoxDriver.prototype.findElementInternal_': Unable to locate element: {"method":"id","selector":"time_entry_activity_id"} (Selenium::WebDriver::Error::NoSuchElementError)
    from [remote server] file:///var/folders/n5/b8s03z3d7ljg5w74qxm_k4500000gn/T/webdriver-profile20140619-17231-9tb59x/extensions/fxdriver@googlecode.com/components/driver_component.js:9479:3:in `FirefoxDriver.prototype.findElement'
    from [remote server] file:///var/folders/n5/b8s03z3d7ljg5w74qxm_k4500000gn/T/webdriver-profile20140619-17231-9tb59x/extensions/fxdriver@googlecode.com/components/command_processor.js:11455:11:in `DelayedCommand.prototype.executeInternal_/h'
    from [remote server] file:///var/folders/n5/b8s03z3d7ljg5w74qxm_k4500000gn/T/webdriver-profile20140619-17231-9tb59x/extensions/fxdriver@googlecode.com/components/command_processor.js:11460:7:in `DelayedCommand.prototype.executeInternal_'
    from [remote server] file:///var/folders/n5/b8s03z3d7ljg5w74qxm_k4500000gn/T/webdriver-profile20140619-17231-9tb59x/extensions/fxdriver@googlecode.com/components/command_processor.js:11402:5:in `DelayedCommand.prototype.execute/<'
    from /Users/hsu-wei-cheng/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/response.rb:51:in `assert_ok'
    from /Users/hsu-wei-cheng/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'

1 个答案:

答案 0 :(得分:0)

alias_method仅接受符号作为参数。尝试不同的方法。