已经搜索了论坛里面所有类似的问题 都试过了都没有解决
检查了所有的环境变量配置问题,也都正常,截图如下:
3、代码如下:
require "rubygems"
require "appium_lib"
require "minitest/autorun"
describe "Basic Android Test" do
def caps
{
caps: {
appiumVersion: "1.4.13",
platformName: "Android",
platformVersion: "4.4",
deviceName: "test",
app: "C:/adt-bundle/XJ.apk",
name: "Basic Android Native Test",
}
}
end
before do
@driver = Appium::Driver.new(caps)
@driver.start_driver
end
after do
@driver.driver_quit
end
describe "when I open the app" do
it "should be able to navigate to the Action Bar" do
el = @driver.find_element :accessibility_id, "App"
el
texts = @driver.find_elements :class_name, "android.widget.TextView"
texts[1].text.must_equal "gonghao"
end
end
end
4.命令行日志报错内容如下:
C:\adt-bundle>ruby test.rb
Run options: --seed 45047
# Running:
E
Finished in 3.193182s, 0.3132 runs/s, 0.0000 assertions/s.
1) Error:
Basic Android Test::when I open the app#test_0001_should be able to navigate to
the Action Bar:
Selenium::WebDriver::Error::ServerError: status code 500
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/remote/response.rb:73:in `assert_ok'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/remote/response.rb:34:in `initialize'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/remote/http/common.rb:78:in `new'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/remote/http/common.rb:78:in `create_response'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/remote/http/default.rb:90:in `request'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/remote/http/common.rb:59:in `call'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/remote/bridge.rb:664:in `raw_execute'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/remote/bridge.rb:122:in `create_session'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/remote/bridge.rb:87:in `initialize'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/common/driver.rb:56:in `new'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/we
bdriver/common/driver.rb:56:in `for'
5、appium 运行日志报错如下:
info: --> POST /wd/hub/session {"desiredCapabilities":{"appiumVersion":"1.4.13",
"platformName":"Android","platformVersion":"4.4","deviceName":"test","app":"C:/a
dt-bundle/XJ.apk"}}
info: Client User-Agent string: appium/ruby_lib/8.0.0
info: [debug] The following desired capabilities were provided, but not recogniz
ed by appium. They will be passed on to any other services running on this serve
r. : appiumVersion
info: [debug] No appActivity desired capability or server param. Parsing from ap
k.
info: [debug] No appPackage desired capability or server param. Parsing from apk
.
info: [debug] Using local app from desired caps: C:\adt-bundle\XJ.apk
info: [debug] Creating new appium session 1fa9ecd4-fafc-4c96-ba8b-c4fd90239361
info: Starting android appium
info: [debug] Getting Java version
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: 'java -version' failed
. Error: Command failed: java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b15)
Java HotSpot(TM) Client VM (build 25.91-b15, mixed mode)
info: [debug] Error: 'java -version' failed. Error: Command failed: java version
"1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b15)
Java HotSpot(TM) Client VM (build 25.91-b15, mixed mode)
at [object Object].<anonymous> (C:\Program Files\Appium\node_modules\appium\
lib\devices\android\android-common.js:1057:17)
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"
A new session could not be created. (Original error: 'java -version' failed. Err
or: Command failed: java version \"1.8.0_91\"\r\nJava(TM) SE Runtime Environment
(build 1.8.0_91-b15)\r\nJava HotSpot(TM) Client VM (build 25.91-b15, mixed mode
)\r\n)","origValue":"'java -version' failed. Error: Command failed: java version