I am working on Android hybrid app. I am using Appium with Ruby.
I am new to Ruby and Appium.
Issue 1
If I start Appium server with port other than default port i.e. 4723, I am not able to set server path/url or Appium port.
I am using following code:
cmd Appium server
appium -a 127.0.0.1 -p 4727 -bp 4728 --chromedriver-port 9517 --no-reset
Ruby Code using Appium Driver:
capabilities = {
‘platformVersion’ => ‘4.4’,
‘platformName’ => ‘Android’,
‘app’ => ‘app\path\Example-debug.apk’,
‘app-package’ => ‘com.appsample’,
‘app-activity’ => ‘.UIActivity’,
‘deviceName’ => ‘Nexus’,
‘newCommandTimeout’ => ‘300’
}
SERVER_URL = “http://127.0.0.1:4727/wd/hub”
@driver = Appium::Driver.new(caps: capabilities, url: SERVER_URL).start_driver
ERROR
ERROR: Unable to connect to Appium. Is the server running? (RuntimeError)
Issue 2
On the other hand if I use Selenium WebDriver instead of Appium Driver, I am able to use desired port however I am not able to use methods like switch to web context, scroll, etc.
Code using Selenium Driver
with same capabilities as above
@driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => SERVER_URL)
webview = @driver.contexts.last
@driver.switch_to.context(webview)
ERROR:
undefined method `contexts’ for #<Selenium::WebDriver::Driver:0xe5fd2ce browser=:Android> (NoMethodError)
Can anyone please help me on this? Am I missing something?