[Appium - Ruby] Unable to start driver


#1

Hi,

I connect a real device but the driver is failed to start.

This is my source code:

require ‘test/unit’
require ‘rubygems’
require ‘appium_lib’

class TestAndroidApp < Test::Unit::TestCase
def setup
desired_caps = {
caps: {
deviceName: ‘Samsung J3’,
udid: ‘42006fd2cc118400’,
platformName: ‘Android’,
platformVersion: ‘5.1.1’,
testName: ‘Android App test with Ruby’,
appPackage: ‘com.sec.android.app.popupcalculator’,
appActivity: ‘com.sec.android.app.popupcalculator.Calculator’
},
appium_lib: {
server_url: ‘http://0.0.0.0:4723/wd/hub
}
}
$driver = Appium::Driver.new(desired_caps)
$driver.start_driver
end

def test_android_app
puts “Hello world”
end

end

This is the error message:

D:\vs-code-workspace\RubyAppium>ruby test2.rb
Loaded suite test2
Started
[DEPRECATION] Appium::Driver.new(opts) will not generate global driver by default.If you would like to generate the global driver dy default, please initialise driver with Appium::Driver.new(opts, true)
E

Error: test_android_app(TestAndroidApp): Errno::EADDRNOTAVAIL: Failed to open TCP connection to 0.0.0.0:4723 (The requested address is not valid in its context. - connect(2) for “0.0.0.0” port 4723)
C:/Ruby24-x64/lib/ruby/2.4.0/net/http.rb:906:in rescue in block in connect' C:/Ruby24-x64/lib/ruby/2.4.0/net/http.rb:903:inblock in connect’
C:/Ruby24-x64/lib/ruby/2.4.0/timeout.rb:93:in block in timeout' C:/Ruby24-x64/lib/ruby/2.4.0/timeout.rb:103:intimeout’
C:/Ruby24-x64/lib/ruby/2.4.0/net/http.rb:902:in connect' C:/Ruby24-x64/lib/ruby/2.4.0/net/http.rb:887:indo_start’
C:/Ruby24-x64/lib/ruby/2.4.0/net/http.rb:876:in start' C:/Ruby24-x64/lib/ruby/2.4.0/net/http.rb:1407:inrequest’
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/default.rb:121:in response_for' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/default.rb:76:inrequest’
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:62:in call' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/bridge.rb:164:inexecute’
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/appium_lib_core-2.0.2/lib/appium_lib_core/common/base/bridge.rb:92:in create_session' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/appium_lib_core-2.0.2/lib/appium_lib_core/common/base/bridge.rb:32:inhandshake’
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/appium_lib_core-2.0.2/lib/appium_lib_core/common/base/driver.rb:20:in initialize' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/appium_lib_core-2.0.2/lib/appium_lib_core/driver.rb:207:innew’
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/appium_lib_core-2.0.2/lib/appium_lib_core/driver.rb:207:in start_driver' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/appium_lib-9.15.1/lib/appium_lib/driver.rb:500:instart_driver’
test2.rb:23:in `setup’

Finished in 6.238809 seconds.

1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
0% passed

0.16 tests/s, 0.00 assertions/s

This is my enviroment:

I started Appium server already
Capture2

Someone please check.
Thx.


#2

I found the problem. It does not work with default host of appium server. I changed the default host then it’s ok.