具体代码如下:
# 返回ls的输出
s=`ls`
cmd= "ls"
s= `#{cmd}`
# 返回true or false
s= system('ls')
cmd= 'ls'
s= system(cmd)
#返回输出
s= %x[uptime]
#用top进程替换当前ruby进程
exec "top"
cmd = 'top'
exec cmd
因为这个元素在60秒内一直没有展现出来吧,所以报了超时,贴下这个方法的源码:#
# Waits until the element is present.
#
# @example
# browser.button(:id =>'foo').wait_until_present
#
# @param [Fixnum] timeout seconds to wait before timing out
#
# @see Watir::Wait
# @see Watir::Element#present?
#
def wait_until_present(timeout = 30)
message = "waiting for #{selector_string} to become present"
Watir::Wait.until(timeout, message) { present? }
end
def until(timeout = 30, message = nil, &block)
end_time = ::Time.now + timeout
until ::Time.now >end_time
result = yield(self)
return result if result
sleep INTERVAL
end
raise TimeoutError, message_for(timeout, message)
end
希望对你有帮助