表单在新选项卡中提交Postsback后,Chrome无响应 - Ruby Watir-Webdriver

时间:2016-03-03 21:52:38

标签: javascript ruby google-chrome selenium watir-webdriver

我正在更新上传文件的脚本,然后在继续上传循环之前从响应中提取数据。

我认为问题是当文件上传并且我正在运行提交表单的javascript(或.click提交)时,Postback会在新选项卡中返回。我相信在等待从提交的页面回发时,watir正在挂起并变得没有响应,但它已经在新标签中打开了(此脚本的旧版本经常使用经典watir的click_no_wait)。脚本超时并且我失去了对窗口的附件,即使我救援超时也无法与浏览器交互。

几天来一直试图解决这个问题。运行一个简单的Ruby行

  p "Submitting..."
  @b.execute_script("javascript:UpldFil();")

以下是已经在响应页面上的此提交的调试:

"Submitting..."
-> POST session/11324ae12918982202d689070e60ee2c/execute
>>> {"script":"javascript:UpldFil();","args":[]}
> {"Content-Length"=>"44", "Content-Type"=>"application/json; charset=utf-8", "Accept"=>"application/json"}
Exception `#<Class:0x5f11b18>' at C:/Ruby187/lib/ruby/1.8/timeout.rb:64 - execution expired
Exception `Timeout::Error' at C:/Ruby187/lib/ruby/1.8/timeout.rb:79 - execution expired

功能UpldFil()

function UpldFil() {
var windowName = "Submission"; 
var fm = document.forms[0];

if (fm.FilNam.value == "") {
alert("Please select a file for submission");
return false;
 }
}   
document.forms[0].submit();

使用: Ruby 1.8.7(2013-06-27 patchlevel 374)[i386-mingw32], 的Watir-webdriver的-0.6.1, Chrome 19

我目前无法更新其中的任何内容,因为它们太多的家属也需要更新。更新和此问题的计划是升级的第1阶段。

在最新的ruby / chrome / webdriver环境中本地运行。这是调试:

"Submitting..."
-> POST session/257d1718ab961a6e92604cfb845ee6ed/execute
>>> http://127.0.0.1:9515/session/257d1718ab961a6e92604cfb845ee6ed/execute |
{"script":"javascript:UpldFil();","args":[]}
> {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"44"}
Exception `IO::EWOULDBLOCKWaitReadable' at C:/Ruby22/lib/ruby/2.2.0/net/protocol.rb:153 - A non-blocking socket operation could not be completed immediately. - read would block
<- {"sessionId":"257d1718ab961a6e92604cfb845ee6ed","status":0,"value":null}
-> DELETE session/257d1718ab961a6e92604cfb845ee6ed
Exception `IO::EWOULDBLOCKWaitReadable' at C:/Ruby22/lib/ruby/2.2.0/net/protocol.rb:153 - A non-blocking socket operation could not be completed immediately. - read would block
<- {"sessionId":"257d1718ab961a6e92604cfb845ee6ed","status":0,"value":null}
#<ChildProcess::Windows::Process:0x4961178 @args=["C:\\tools/chromedriver.exe",
"--port=9515"], @started=true, @exit_code=nil, @io=nil, @cwd=nil, @detach=false, @duplex=false, @leader=false, @environment={}, @pid=5040, @handle=#<ChildProcess::Windows::Handle:0x4960e00 @pid=5040, @pointer=#<FFI::Pointer address=0x0002d8>, @closed=false>> : [{:exited?=>false, :code=>259}]
Exception `IO::EWOULDBLOCKWaitReadable' at C:/Ruby22/lib/ruby/2.2.0/net/protocol.rb:153 - A non-blocking socket operation could not be completed immediately. - read would block
#<ChildProcess::Windows::Process:0x4961178 @args=["C:\\tools/chromedriver.exe", "--port=9515"], @started=true, @exit_code=nil, @io=nil, @cwd=nil, @detach=false, @duplex=false, @leader=false, @environment={}, @pid=5040, @handle=#<ChildProcess::Windows::Handle:0x4960e00 @pid=5040, @pointer=#<FFI::Pointer address=0x0002d8>, @closed=false>> : ["polling 5 seconds for exit"]

继续调试以吐出20-30个ChildProcess行,浏览器崩溃并关闭。

0 个答案:

没有答案