我正在编写一个脚本来自动从网页上保存为流程。
基本上有一个网站上有一个名为PREVIEW
的按钮。步骤将是:
CODE
require 'selenium-webdriver'
require 'win32ole'
require "au3"
require 'rautomation'
driver = Selenium::WebDriver.for:firefox
driver.manage().window().maximize();
driver.navigate.to 'C:\Users\js830363\Documents\Userdata\GOI\New_Sahi\Ruby_Final\Demo2.html'
wait = Selenium::WebDriver::Wait.new(:timeout =>180)
wait.until {driver.find_element(:id,'Button1').click} #ID OF Print Button to click
//Till Here it work fine.I get a print dialog box in firefox after that I have tried with
Autoit:
#Wait for the window to exist
AutoItX3::Window.wait("Print") #The start of the title is enough to find it
window = AutoItX3::Window.new("Print")#Get a reference to it
window.activate #Bring it to the front
AutoItX3::window.controlClick("Print", "", "1057")#id of OK and Cancel Button
window.controlClick("Print", "", "1058")
Rautomation:
win = RAutomation::Window.new :title => /Opening rautomation/, :adapter => :ms_uia
win.send_keys :enter
file_dialog = RAutomation::Window.new :title => /Enter name of file/
file_dialog.button(:value => "&Save").click
错误
C:\Users\js830363\Desktop>ruby test1.rb
C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:158:in `rescue in
rbuf_fill': Net::Rea dTimeout (Net::ReadTimeout)
from C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:152:in `rbuf_fill'
from C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:134:in `readuntil'
from C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:144:in `readline'
from C:/Ruby200/lib/ruby/2.0.0/net/http/response.rb:39:in `read_status_line'
我正在使用ruby 2.0.0和Selenium Webdriver以及AutorIt我也尝试过使用reautomation但是无法点击打印按钮。