0

我试图让我的测试自动授予带有上限的权限,但总是当我尝试这样做时,我得到了一个 InvalidArgumentError。我该如何解决这个问题?

我正在尝试什么:

require 'rubygems'
require 'em/pure_ruby'
require 'appium_lib'
require 'eventmachine'
require 'selenium-webdriver'

caps = {}
caps["app"] = "C:/apk/Pb_debug_4.1.19-DEBUG1-20190416T143413Z-001/Pb_debug_4.1.19-DEBUG1/Pb_debug_4.1.19-DEBUG.apk"
caps["platformName"] = "Android"
caps["platformVersion"] = "7.0"
caps["deviceName"] = "EMULATOR29X0X6X0"
caps["autoAcceptAlerts"] = "True"
caps["newCommandTimeout"] = "3600"
caps["deviceReadyTimeout"] = "3600"
caps["automationName"] = "UiAutomator2"
caps["autoGrantPermissions"] = "True"

错误:

InvalidArgumentError: 'autoGrantPermissions' must be of type boolean: 'autoGrantPermissions' must be of type boolean (Selenium::WebDriver::Error::InvalidArgumentError)
from     at validateCaps (C:\appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\capabilities.js:52:11)
from     at validateCaps (C:\appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\capabilities.js:154:20)
from     at parseCaps (C:\appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\capabilities.js:199:43)
from     at AndroidUiautomator2Driver.commands.createSession (C:\appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\session.js:36:14)
from     at AndroidUiautomator2Driver.createSession (C:\appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:150:43)
from     at AppiumDriver.createSession (C:\appium\resources\app\node_modules\appium\lib\appium.js:301:43)
from     at process._tickCallback (internal/process/next_tick.js:68:7)
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.0/lib/selenium/webdriver/remote/response.rb:72:in `assert_ok'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.0/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.0/lib/selenium/webdriver/remote/http/common.rb:88:in `new'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.0/lib/selenium/webdriver/remote/http/common.rb:88:in `create_response'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.0/lib/selenium/webdriver/remote/http/default.rb:114:in `request'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.1.1/lib/appium_lib_core/common/base/http_default.rb:81:in `call'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.0/lib/selenium/webdriver/remote/bridge.rb:167:in `execute'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.1.1/lib/appium_lib_core/common/base/bridge.rb:107:in `create_session'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.1.1/lib/appium_lib_core/common/base/bridge.rb:47:in `handshake'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.1.1/lib/appium_lib_core/common/base/driver.rb:34:in `initialize'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.1.1/lib/appium_lib_core/driver.rb:348:in `new'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.1.1/lib/appium_lib_core/driver.rb:348:in `start_driver'
from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib-10.3.1/lib/appium_lib/driver.rb:548:in `start_driver'
from C:/qa/test.rb:29:in `<main>'
[Finished in 4.2s with exit code 1]

我真的不知道该怎么做才能解决这个问题。感谢您的关注。

4

2 回答 2

2

只需更改此:

caps["autoGrantPermissions"] = "True"

至:

caps["autoGrantPermissions"] = true
于 2019-05-15T04:49:00.133 回答
0

您在双引号内使用 True ,这就是为什么它被视为字符串而不是布尔值的原因。您应该尝试更改caps["autoGrantPermissions"] = "True"caps["autoGrantPermissions"] = true.

于 2019-05-15T07:11:27.180 回答