我有一个非常简单的脚本作为冒烟测试。
该脚本执行以下操作:
- 注册驱动程序
- 驱动程序导航到“ https://www.google.co.uk/ ”
- 司机下车
脚本:
require 'selenium-webdriver'
driver = Selenium::WebDriver.for(:edge)
driver.navigate.to("https://www.google.co.uk/")
driver.quit
当我运行它时,驱动程序打开 Edge,导航到谷歌,MicrosoftWebDriver 在“退出”方法之前停止,导致 ruby 引发错误。
下面是控制台的输出:
PS C:\projects\sandbox> ruby test.rb
2017-09-22 11:54:32 DEBUG Selenium Executing Process ["C:/WebDrivers/MicrosoftWebDriver.exe", "--port=17556"]
Listening on http://localhost:17556/
2017-09-22 11:54:32 INFO Selenium -> POST session
2017-09-22 11:54:32 INFO Selenium >>> http://localhost:17556/session | {"desiredCapabilities":{"browserName":"MicrosoftEdge","platform":"WINDOWS"},"capabilities":{"firstMatch":[{"browserName":"MicrosoftEdge"}]}}
2017-09-22 11:54:32 DEBUG Selenium > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"140"}
2017-09-22 11:54:33 INFO Selenium <- {"sessionId":"EAB1B8C2-DF58-4DED-BD52-8386F1FC9B0A","status":0,"value":{"browserName":"MicrosoftEdge","browserVersion":"25.10586.672.0","platformName":"windows","platformVersion":
"10","takesElementScreenshot":true,"takesScreenshot":true,"acceptSslCerts":true,"pageLoadStrategy":"normal"}}
2017-09-22 11:54:33 INFO Selenium Detected OSS dialect.
2017-09-22 11:54:33 INFO Selenium Forcing W3C dialect.
2017-09-22 11:54:33 INFO Selenium -> POST session/EAB1B8C2-DF58-4DED-BD52-8386F1FC9B0A/url
2017-09-22 11:54:33 INFO Selenium >>> http://localhost:17556/session/EAB1B8C2-DF58-4DED-BD52-8386F1FC9B0A/url | {"url":"https://www.google.co.uk/"}
2017-09-22 11:54:33 DEBUG Selenium > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"35"}
2017-09-22 11:54:33 INFO Selenium <- {"sessionId":"EAB1B8C2-DF58-4DED-BD52-8386F1FC9B0A","status":0,"value":null}
2017-09-22 11:54:34 INFO Selenium -> DELETE session/EAB1B8C2-DF58-4DED-BD52-8386F1FC9B0A
2017-09-22 11:54:35 INFO Selenium <- {"sessionId":"EAB1B8C2-DF58-4DED-BD52-8386F1FC9B0A","status":0,"value":null}
Stopping server.
C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect': Failed to open TCP connection to localhost:17556 (No connection could be made because the target machine actively refused it. - connect(2)
for "localhost" port 17556) (Errno::ECONNREFUSED)
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'
from C:/Ruby23-x64/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
from C:/Ruby23-x64/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:878:in `connect'
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:1476:in `begin_transport'
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:1433:in `transport_request'
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:1407:in `request'
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:1156:in `get'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.5.2/lib/selenium/webdriver/common/service.rb:130:in `block in stop_server'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.5.2/lib/selenium/webdriver/common/service.rb:110:in `block in connect_to_server'
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:853:in `start'
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:584:in `start'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.5.2/lib/selenium/webdriver/common/service.rb:106:in `connect_to_server'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.5.2/lib/selenium/webdriver/common/service.rb:130:in `stop_server'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.5.2/lib/selenium/webdriver/common/service.rb:79:in `stop'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.5.2/lib/selenium/webdriver/edge/driver.rb:74:in `quit'
from test.rb:29:in `<main>'
我已经尝试解决此问题:
- 我已禁用防火墙并关闭了防病毒软件
- 尝试了不同版本的 MicrosoftWebDriver
- 尝试了不同版本的 SeleniumDriver