Appium + Watir + Chromedriver处理命令时发生未知的服务器端错误

时间:2018-10-21 01:36:50

标签: ruby mobile cucumber appium watir

我的项目中有以下代码:

features / env.rb

require 'rubygems'
require 'rspec'
require 'watir'
require 'webdrivers'
require 'yaml'
require 'fileutils'
require './features/Util/Tools.rb'
require 'json'
require 'watir-scroll'
require "mini_magick"
require 'watir-screenshot-stitch'
require 'appium_lib'
require 'selenium-webdriver'

    server_url = 'http://localhost:4723/wd/hub/'

    capabilities =
    {
    platformName: 'Android',
    platformVersion: '7.0',
    deviceName: 'Android Emulator',
    browserName: 'Chrome'
    }

    $navegador = "chrome_dev_mobile"

    $appium_driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => server_url)

    $driver Watir::Browser.new $appium_driver

当我运行黄瓜功能时,出现此错误:

And Verificar Portal abierto                   # features/step_definitions/Home/Home_Chile/SD1_Home.rb:16
  An unknown server-side error occurred while processing the command. Original error: unknown error: Argument to isShown must be of type Element
    (Session info: chrome=69.0.3497.100)
    (Driver info: chromedriver=2.42.591059 (a3d9684d10d61aa0c45f6723b327283be1ebaad8),platform=Mac OS X 10.13.6 x86_64) (Selenium::WebDriver::Error::UnknownError)
  UnknownError: An unknown server-side error occurred while processing the command. Original error: unknown error: Argument to isShown must be of type Element
    (Session info: chrome=69.0.3497.100)
    (Driver info: chromedriver=2.42.591059 (a3d9684d10d61aa0c45f6723b327283be1ebaad8),platform=Mac OS X 10.13.6 x86_64)
      at errorFromMJSONWPStatusCode (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:789:10)
      at ProxyRequestError.getActualError (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:683:14)
      at asyncHandler$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:400:25)
      at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
      at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
      at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
      at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
      at <anonymous>
  ./features/pages/Home/Home_Page/P1_HomePage.rb:20:in `verificar_pagina'
  ./features/step_definitions/Home/Home_Chile/SD1_Home.rb:17:in `"Verificar Portal abierto"'
  features/features/Pruebas_Mobile/CL_Mobile.feature:4:in `And Verificar Portal abierto'

那是./features/pages/Home/Home_Page/P1_HomePage.rb:20

中的代码
def verificar_pagina
      @caja_busqueda.wait_until_present
      if @caja_busqueda.present?
        puts "Portal abierto satisfactoriamente con: " + $navegador
      end
  end

移动浏览器打开我的URL,然后出现此错误。请尝试一切,我接受建议

我手动设置了appium chromedriver路径,并很好地使用了它。 查看appium日志显示以下内容以及更多详细信息:

[JSONWP Proxy] Got response with status 200: {"sessionId":"d8b3f057fdc1e6e20a0007f9ed920514","status":13,"value":{"message":"unknown error: Argument to isShown must be of type Element\n  (Session info: chrome=69.0.3497.100)\n  (Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)"}}
[W3C] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: The request to /wd/hub/session/3345408e-82f9-4f63-b6ec-f82998806f47/execute has failed
[W3C]     at JWProxy.proxy$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:182:13)
[W3C]     at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[W3C]     at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[W3C]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[W3C]     at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[W3C]     at 
[MJSONWP] Matched JSONWP error code 13 to UnknownError
[HTTP] <-- POST /wd/hub/session/3345408e-82f9-4f63-b6ec-f82998806f47/execute/sync 500 110 ms - 1894
[HTTP] 

2 个答案:

答案 0 :(得分:0)

  

(会话信息:chrome = 69.0.3497.100)和(驱动程序信息:chromedriver = 2.42.591059

this chromedriver page上,他们说您应该为Chrome 69-71v使用驱动程序2.43。 更新网络驱动程序是否可以解决您的问题? v2.42还应该仍然支持版本69。但是提到了很多修补程序,例如:

  

固定不等元素可见

当我通过桌面应用程序启动appium时,我也注意到了同样的isShown问题。但是,为我解决的是手动下载chromedriver并通过this Appium page中所述的命令提示符启动appium。

appium --chromedriver-executable /path/to/my/chromedriver

答案 1 :(得分:0)

我以此方式证明:

require 'watir'
require 'selenium-webdriver'

    server_url = 'http://localhost:4723/wd/hub/'

    capabilities =
    {
    platformName: 'Android',
    platformVersion: '7.0',
    deviceName: 'Android Emulator',
    browserName: 'chrome'
    }


    $driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => server_url)

    $driver.get "http://www.google.com"

有效!

但是当推入

$appium_driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => server_url)
$driver = Watir::Browser.new $appium_driver

然后在尝试与定位器进行交互时显示错误。

也许我不知道沃特尔与硒和鸦片之间存在冲突。 太可惜了,因为我在Watir上做了一个完整的网页设计项目,而我无法在移动设备测试中重复使用所有这些代码。

任何建议都会被接受