Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
找不到已连接的Android设备_Android_Ruby_Selenium_Cucumber_Appium - Fatal编程技术网

找不到已连接的Android设备

找不到已连接的Android设备,android,ruby,selenium,cucumber,appium,Android,Ruby,Selenium,Cucumber,Appium,我无法启动android emulator来运行我的自动化脚本 但是,当我使用emulator-avd Pixel\u API\u 25-端口5557从/android/sdk/tools目录手动启动android emulator时,我的自动化脚本可以工作 我希望能够在我的自动化脚本中加载android仿真器 请参阅下面我的env.rb文件 require 'rubygems' require 'rspec/expectations' require 'selenium-webdriver'

我无法启动android emulator来运行我的自动化脚本

但是,当我使用
emulator-avd Pixel\u API\u 25-端口5557从
/android/sdk/tools
目录手动启动android emulator时,我的自动化脚本可以工作

我希望能够在我的自动化脚本中加载android仿真器

请参阅下面我的env.rb文件

require 'rubygems'
require 'rspec/expectations'
require 'selenium-webdriver'
require 'pry'
require 'appium_lib'

APP_PATH = '/Users/shafiq.malik/Documents/Projects/nuff-class-booking-
mobile/platforms/ios/build/emulator/HelloCordova.app'

  desired_caps = {
      caps: {:platformName => "Android",
             :platformVersion => "7.1.1",
             :deviceName => "Pixel_API_25",
             :app => "/Users/shafiq.malik/Documents/Projects/nuff-
             class-booking-
             mobile/platforms/android/build/outputs/apk/android-
             debug.apk",
             :appPackage => "com.android.settings",
             #:appActivity => ".Settings",
             :browserName =>''
             }

  }

@driver = Appium::Driver.new(desired_caps).start_driver
Appium.promote_appium_methods self.class

def server_url
  'http://localhost:8000/wd/hub'
end

有人有什么建议吗?

尝试将其添加到您想要的功能中。您需要
avd
功能才能启动仿真器

在爪哇
capabilities.setCapability(“avd”、“AndroidTestDevice”)

对于ruby,这两种语言中的任意一种

  • avd:“AndroidTestDevice”,
  • :avd=>“AndroidTestDevice”,
  • 你想要的帽子应该是这样的

    desired_caps = {
          caps: {:platformName => "Android",
                 :platformVersion => "7.1.1",
                 :deviceName => "Pixel_API_25",
                 :app => "/Users/shafiq.malik/Documents/Projects/nuff-
                 class-booking-
                 mobile/platforms/android/build/outputs/apk/android-
                 debug.apk",
                 :appPackage => "com.android.settings",
                 `:avd => "AndroidTestDevice",`
                 #:appActivity => ".Settings",
                 :browserName =>''
                 }
    
      }
    

    另一方面,不要将根目录作为应用程序的文件路径。如果您使用的是CI,而使用的是一个通用代码,您只能在其中指明
    .apk
    .app/.ipa
    名称,这可能会在以后导致问题。

    您使用的是哪种appium版本?您是否尝试在应用程序中选中
    launch AVD
    选项?如果它不可用,您可以尝试将
    AVD
    添加到所需的功能中,然后重新检查吗?这将启动模拟器。我在Android Studio中创建的设备使用的不是AndroidTestDevice,而是AndroidTestDevice。但是,它没有加载应用程序并给我
    原始错误:启动应用程序时发生错误。原始错误:用于启动应用程序的活动不存在或无法启动!确保它存在并且是可启动的活动(Selenium::WebDriver::Error::UnknownError)
    我如何才能让应用程序弹出并使用该应用程序?顺便问一下,您使用此代码的目的是什么
    APP_PATH='/Users/shafiq.malik/Documents/Projects/nuff-class-booking-mobile/platforms/ios/build/emulator/HelloCordova.APP'
    。考虑到您正在执行android测试是的,我是,我希望能够测试android应用。@ShafiqAhmedMalik您需要转到appium并取消选中“可启动活动”选项我对appium很陌生。我该怎么做?