Selenium / Rudy:'未初始化的常量Contactlist :: Runtime(NameError)'错误

时间:2017-05-24 09:00:56

标签: ruby selenium runtime

为了在Ruby-selenium环境中执行Runtime.getRuntime().exec("Script.exe"),我应该初始化什么命令?

代码:

class Contactlist
    require "selenium-webdriver"
    require "rubygems"
    require "test/unit"

    driver = Selenium::WebDriver.for :firefox
        driver.navigate.to "https://www.contactually.com/"
        sleep 20
      element = driver.find_element(:css, ".signin>a").click
     sleep 5
      element = driver.find_element(:css, "#user_email")
      element.send_keys "pcroyalpaint@gmail.com"
      element = driver.find_element(:css, "#user_password")
      element.send_keys "Astegic1!"
      element = driver.find_element(:css, ".callout.sign-in-btn").click
      sleep 15
    element = driver.find_element(:xpath, ".//*[@class='ui inverted underlined ApplicationHeader__main-menu___1gsj_ menu']//a[2]").click
    sleep 10
    element = driver.find_element(:xpath,"/.//a[@ href='https://www.contactually.com/contacts/import']").click
    sleep 10
    element =  driver.find_element(:xpath,".//*[@id='file']").click
 Runtime.getRuntime().exec("Script.exe")
end

控制台输出:

enter image description here

1 个答案:

答案 0 :(得分:0)

Runtime不是标准ruby中的对象(看起来Runtime.getRuntime().exec()来自java?)。但是,如果这是在其他地方实施的,那么您需要requireinclude

如果您只是尝试在shell级别执行命令,则可以使用system('script.exe')