【问题标题】:autoGrantPermissions as boolean type, how?autoGrantPermissions 作为布尔类型,如何?
【发布时间】:2019-10-02 03:48:43
【问题描述】:

我试图让我的测试自动授予带有大写的权限,但是当我尝试这样做时,我总是得到一个 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]

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

【问题讨论】:

    标签: ruby selenium-webdriver appium appium-android appium-desktop


    【解决方案1】:

    只要改变这个:

    caps["autoGrantPermissions"] = "True"
    

    到:

    caps["autoGrantPermissions"] = true
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-15
        相关资源
        最近更新 更多