GithubHelp home page GithubHelp logo

appium_capybara's Introduction

appium_capybara Gem Version

Documentation

Gem enabling appium support in capybara

Please use v1.4.1 for Capybara 2.x users. v1.5.0 requires Capybara 3.x.

Driver Setup

Set up the appium_capybara driver by running this before starting your test.

require 'appium_capybara'

desired_caps_ios = {
  platform:        "Mac",
  deviceName:      "iPhone Simulator",
  platformName:    "iOS",
  platformVersion: "12.4",
  app:             "full/path/to/app.zip"
}

url = "http://localhost:4723/wd/hub" # or a sauce labs url

Capybara.register_driver(:appium) do |app|
    appium_lib_options = {
      server_url: url
    }
    all_options = {
      appium_lib: appium_lib_options,
      caps: desired_caps_ios
    }
    Appium::Capybara::Driver.new app, all_options
end

Capybara.default_driver = :appium

Capybara server

appium_capybara driver automatically starts a Rails server in test environment.

By default Capybara starts this web server listening to localhost only and on a random port. It is advised to force Capybara to listen to all interface and listen to a specific port, and set this server address in your mobile application.

Capybara.server_host = '0.0.0.0' # Listen to all interfaces
Capybara.server_port = 56844     # Open port TCP 56844, change at your convenience

Call methods

appium_capybara provides both Capybara methods and appium_lib methods.

capy_driver = Capybara.current_session.driver

# Calls methods defined in Appium::Capybara::Driver and Capybara::Selenium::Driver
capy_driver.find_custom :name, '<enter text>'

# Calls methods defined in only appium_lib (Appium::Driver)
capy_driver.appium_driver.find_element(:name, 'TextFields').click
capy_driver.appium_driver.hide_keyboard

Publishing to rubygems

Make sure to run thor bump or manually modify version.rb before publishing. RubyGems will not allow the same version to be published twice. After the version is bumped, run thor publish

major changelogs

  • v3.0.0

    • Support Ruby 3+ only
  • v2.0.0

    • Bump base appium_lib version to v12
    • Bump base capybara version to over 3.36
    • Support Ruby 2.6+

appium_capybara's People

Contributors

aha-oretama avatar bootstraponline avatar doctolib-eric avatar kazucocoa avatar maudineormsby avatar mishaaq avatar prashanth-sams avatar randoum avatar rjaros87 avatar sbonebrake avatar teyamagu avatar vgrigoruk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appium_capybara's Issues

NotImplementedError (NotImplementedError)

Hi

I am the folowing set up in terms of Gems on my local machine,

appium_capybara (0.0.2)
  appium_lib (~> 4, >= 4.1.0)
  capybara (~> 2.4, >= 2.4.1)
appium_lib (4.1.0)
  awesome_print (~> 1.2, >= 1.2.0)
  json (~> 1.8, >= 1.8.1)
  nokogiri (~> 1.6.1)
  selenium-webdriver (~> 2.41, >= 2.41.0)
  toml (~> 0.0, >= 0.0.4)
awesome_print (1.2.0)
blankslate (2.1.2.4)
builder (3.2.2)
capybara (2.4.1)
  mime-types (>= 1.16)
  nokogiri (>= 1.3.3)
  rack (>= 1.0.0)
  rack-test (>= 0.5.4)
  xpath (~> 2.0)
site_prism (2.6)
  addressable (~> 2.3.3)
  capybara (>= 2.1, < 3.0)

And when I execute a step I get the following error,

Given I am on the homepage                                  # features/step_definitions/navigation_steps.rb:1
  NotImplementedError (NotImplementedError)
  ./features/step_definitions/navigation_steps.rb:2:in `/^I am on the homepage$/'

Step definition

Given(/^I am on the homepage$/) do
home_page.load
end

Conection to the appium selenium driver:

require 'appium_capybara'

desired_caps_ios = {
  :platformName => "Android",
  :browserName => "chrome",
  :deviceName => "Android"
}

url = "http://localhost:4723/wd/hub"

Capybara.register_driver(:appium) do |app|
  appium_lib_options = {
    server_url: url
  }
  all_options = {
    appium_lib:  appium_lib_options,
    caps:        desired_caps_ios
  }
  Appium::Capybara::Driver.new app, all_options
end

Capybara.default_driver = :appium

I suspect is the load method. I have changed it to visit method and I get the same error.

Support for context switching

Hi-
I have searched through the code/issues, and although I see some references to context switching and hybrid apps, they do not appear to be supported by the code. I have patched the code(example below) for my own use.

module Appium::Capybara
  class Appium::Capybara::Driver
    def set_context context
      browser.set_context context
    end
  end
end

Has anyone tried to implement this? It seems fairly straightforward and works fine in iOS and selendroid, but I am running into an issue with chromedriver on sauce when I try to switch contexts. Is there any documented reason why the context methods haven't been implemented?

Edit: The chromedriver error is below. I don't get any error when I run this locally on a real device or run this request straight through the vanilla appium selenium driver.

Did not get session redirect from Chromedriver (Selenium::WebDriver::Error::UnknownError)
      ./common/appium.rb:9:in `set_context'

[appium_lib, ruby, capybara, site_prism] UIAElements don't have the attribute 'isContentEditable'

Hello!

I'm using ruby 2.1.1, appium_lib 4.1.0, appium_capybara 0.0.2, selenium-webdriver 2.41.0.

With site_prism, I'm defining page object elements for an IOS Native application, as follows:

element :domain, :xpath, "//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]"
element :first_name, :xpath, "//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[2]"
element :password, :xpath, "//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIASecureTextField[1]"

When trying to execute the following line:
@mobile_login.domain.set 'mydomain.net'
@mobile_login.first_name.set 'axel'
@mobile_login.password.set 'axel1'

I receive the following error in the console:

UIAElements don't have the attribute 'isContentEditable' (Selenium::WebDriver::Error::UnknownCommandError)
Not implemented in this context, try switching into or out of a web view (Selenium::WebDriver::Error::UnknownError)
/home/rodrigomartin/.rvm/gems/ruby-2.1.1@mobileIOS-automation/gems/selenium-webdriver-2.41.0/lib/selenium/webdriver/remote/response.rb:51:in assert_ok' /home/rodrigomartin/.rvm/gems/ruby-2.1.1@mobileIOS-automation/gems/selenium-webdriver-2.41.0/lib/selenium/webdriver/remote/response.rb:15:ininitialize'
/home/rodrigomartin/.rvm/gems/ruby-2.1.1@mobileIOS-automation/gems/selenium-webdriver-2.41.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'

Any help on this will be really appreciated.
If you need more info, please let me know.

Regards!

Cannot call rotate method

Hi,

I've added your gem into my gemfile, but when calling the rotate method in the steps it tells me it's not defined. Am I missing something?

Not able to call rotate method

I used below configurations but not able to call rotate method using
[11] pry(main)> capy_driver.rotate :landscape
[12] pry(main)> capy_driver.rotate :portrait

Error:
Selenium::WebDriver::Error::NoSuchDriverError: A session is either terminated or not started

configurations:
require 'appium_capybara'

capabilities = {
deviceName: "iPhone 7",
platformName: "iOS",
app: ipa_file_path,
automationName: "XCUITest",
platformVersion: "10.3.3",
udid: "",
showXcodeLog: "true",
xcodeOrgId: "
",
xcodeSigningId: "* Developer",
autoGrantPermissions: true
}

Capybara.register_driver(:appium) do |app|
appium_lib_options = {
server_url: url
}
all_options = {
appium_lib: appium_lib_options,
caps: capabilities
}
@driver_appium = Appium::Capybara::Driver.new app, all_options
end

Capybara.default_driver = :appium

capy_driver = Capybara.current_session.driver

..........

My driver contains look like below:
#<Appium::Driver:0x007fbc79d0fe48
@appium_debug=true,
@appium_device=:ios,
@appium_port=4723,
@appium_server_status={"build"=>{"version"=>"1.6.5", "revision"=>nil}},
@appium_wait_interval=0.5,
@appium_wait_timeout=30,
@automation_name=:xcuitest,
@caps=
#<Selenium::WebDriver::Remote::W3C::Capabilities:0x007fbc79d0fa10
@capabilities=
{:deviceName=>"iPhone 7",
:platformName=>"iOS",
:app=>"app.ipa",
:automationName=>"XCUITest",
:platformVersion=>"10.3.3",
:udid=>"",
:showXcodeLog=>"true",
:xcodeOrgId=>"
",
:xcodeSigningId=>"
Developer",
:autoGrantPermissions=>true,
:proxy=>nil}>,
@custom_url="http://localhost:4723/wd/hub",
@default_wait=0,
@driver=#<Selenium::WebDriver::Remote::Driver:0x..f795fb501b57dbca browser=:"">,
@export_session=false,
@http_client=
#<Selenium::WebDriver::Remote::Http::Default:0x007fbc785ca300
@http=#<Net::HTTP localhost:4723 open=false>,
@open_timeout=999999,
@Proxy=nil,
@read_timeout=999999,
@server_url=#<URI::HTTP http://localhost:4723/wd/hub/>>,
@Listener=nil,
@sauce_access_key=nil,
@sauce_endpoint="ondemand.saucelabs.com:443/wd/hub",
@sauce_username=nil>

Could not find any webviews, hence Safari never finishes initializing

Given this rspec test:

require_relative "spec_helper"
describe "Test IOS stuff", js: true, type: :feature  do
  let!(:author)  { an_author_with_login(first_name:"Author", last_name:"author") }
  let!(:learner) { a_learner(first_name: "young", last_name:"student") }
  let!(:admin)   { an_account_admin_with_login(first_name: "mr", last_name: "Admin") }

  example "Login as learner" do
    login_as learner
  end
  example "Login as author" do
    login_as author
  end
  example "Login as admin" do
    login_as admin
  end
end

When I run it, appium_capybara launches IOS and starts Safari, and attempts to load an initial URL. Which is hard-coded to http://0.0.0.0:4723/welcome, if you don't override it in the capabilities (Take a wild guess where!!!). I don't care what the initial URL is, since when you navigate to your first page, it gets lost anyways. But I know from the appium developers that the initial URL is needed to fully and correctly instantiate a webview (on IOS). OK, fine.

But what is happening with me, now is that the 'initial' URL is not getting loaded in Safari. It's like the tap button didn't get pressed or something.

So the address is put in the field, and then the re-load button gets pressed over and over and over again.

In my appium log I'm seeing this repeated over and over again:

warn: Could not find any webviews yet, refreshing/retrying
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: "au.getElementByAccessibilityId('ReloadButton')"
info: [debug] Sending command to instruments: au.getElementByAccessibilityId('ReloadButton')
info: [debug] Socket data received (40 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":{"ELEMENT":"100"}}
info: [debug] Pushing command to appium work queue: "au.tapById('100')"
info: [debug] Sending command to instruments: au.tapById('100')
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: Got new command 201 from instruments: au.getElementByAccessibilityId('ReloadButton')
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: evaluating au.getElementByAccessibilityId('ReloadButton')
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: Lookup returned [object UIAButton] with the name "ReloadButton" (id: 100).
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: responding with:
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: Running system command #202: /usr/local/Cellar/node/0.12.4/bin/node /Users/cjohnson/    code/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"ELEMENT":"100"}}...
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: Got new command 202 from instruments: au.tapById('100')
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: evaluating au.tapById('100')
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: UIAButton.tap()
info: --> GET /welcome {}
info: <-- GET /welcome 200 0.699 ms - 128
info: [debug] Socket data received (25 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":""}
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: responding with:
info: [debug] [INST] 2015-06-19 19:01:04 +0000 Debug: Running system command #203: /usr/local/Cellar/node/0.12.4/bin/node /Users/cjohnson/    code/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":""}...
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] {"__argument":{"WIRApplicationIdentifierKey":"PID:88410","WIRListingKey":{"1":{"WIRTitleKey":"Appium/    welcome","WIRTypeKey":"WIRTypeWeb","WIRURLKey":"http://127.0.0.1:4723/    welcome","WIRPageIdentifierKey":1}}},"__selector":"_rpc_applicationSentListing:"}
info: [debug] [REMOTE] New page listing did not match the app id we are currently using, ignoring
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] {"__argument":{"WIRApplicationIdentifierKey":"PID:88410","WIRListingKey":{"1":{"WIRTitleKey":"Appium/    welcome","WIRTypeKey":"WIRTypeWeb","WIRURLKey":"http://127.0.0.1:4723/    welcome","WIRPageIdentifierKey":1}}},"__selector":"_rpc_applicationSentListing:"}
info: [debug] [REMOTE] New page listing did not match the app id we are currently using, ignoring
info: [IOS_SYSLOG_ROW ] Jun 19 13:01:05 cjohnson-laptop.corp.instructure.com lsuseractivityd[88368]: [SFActivityAdvertiser] ERROR: no XPC     proxy, queuing advertisement <55391abd 70f90f01 ac>
info: [debug] [REMOTE] Selecting app PID:88400 (try #1 of 8)
info: [debug] [REMOTE] Sending _rpc_forwardGetListing: message to remote debugger
info: [debug] [REMOTE] {"__argument":{"WIRConnectionIdentifierKey":"ea4ebe66-7621-43a2-aa45-    e840da5f1d1d","WIRApplicationIdentifierKey":"PID:88400"},"__selector":"_rpc_forwardGetListing:"}
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] {"__argument":{"WIRApplicationIdentifierKey":"PID:88400","WIRListingKey":{"1":{"WIRTitleKey":"","WIRTypeKey":"WIRTypeW    eb","WIRURLKey":"about:blank","WIRPageIdentifierKey":1}}},"__selector":"_rpc_applicationSentListing:"}
info: [debug] [REMOTE] Connected to app PID:88400 [[{"id":1,"title":"","url":"about:blank","isKey":false}]]

The only thing is, the 'id' keeps getting incremented every iteration:

Sending command to instruments: au.tapById('100')
Sending command to instruments: au.tapById('101')
Sending command to instruments: au.tapById('102')
Sending command to instruments: au.tapById('103')

etc...

And here is the relevant code in my spec_helper.rb

Capybara.register_driver(:appium) do |app|
  # Set the ip address of the where the browser will navigate to
  Capybara.app_host = ENV["BRIDGE_HOST"]
  # By default Capybara starts this web server listening to localhost only
  # It is advised to force Capybara to listen to all interfaces
  Capybara.server_host = "0.0.0.0"
  # instead of using a random port, let's just use one we pick
  Capybara.server_port = 5567
  # To start the server, install the appium tools
  # and start the Appium server with this url
  url = "http://0.0.0.0:4723/wd/hub"

  # Setup the capabilities
  desired_caps_ios = {
    platform:        "Mac",
    platformName:    "iOS",
    platformVersion: "8.3",
    browserName: "Safari",
    noReset: true
  }

  # For a list of devices we can assign for the :deviceName, See the documentation here:
  # http://appium.io/slate/en/master/?ruby#server-flags
  # specifically this command:
  # instruments -s devices
  case ENV["APPIUM_DEVICE"]
    when "IPad"
      desired_caps_ios[:deviceName] = "iPad Air"
    when "IPhone"
      desired_caps_ios[:deviceName] = "iPhone 6 Plus"
    else
      desired_caps_ios[:deviceName] = "iPad Simulator"
  end

  appium_lib_options = {
    server_url:           url,
    debug: false # Turn off a deluge of debugging messages
  }
  all_options = {
    browser: :safari,
    appium_lib:  appium_lib_options,
    caps:        desired_caps_ios,
  }

  Appium::Capybara::Driver.new app, all_options
end

wrong number of arguments (given 2, expected 1) using Capybara 3.x

Using newest Capybara 3.2.1 during tests throw error:

ArgumentError:
       wrong number of arguments (given 2, expected 1)
     # /Users/jaror/.rvm/gems/ruby-2.4.1/gems/appium_capybara-1.5.0/lib/appium_capybara/driver/appium/node.rb:12:in `set'
     # /Users/jaror/.rvm/gems/ruby-2.4.1/gems/capybara-3.2.1/lib/capybara/node/element.rb:93:in `block in set'
     # /Users/jaror/.rvm/gems/ruby-2.4.1/gems/capybara-3.2.1/lib/capybara/node/base.rb:83:in `synchronize'
     # /Users/jaror/.rvm/gems/ruby-2.4.1/gems/capybara-3.2.1/lib/capybara/node/element.rb:93:in `set'
     # /Users/jaror/.rvm/gems/ruby-2.4.1/gems/capybara-3.2.1/lib/capybara/node/actions.rb:85:in `fill_in'
     # /Users/jaror/.rvm/gems/ruby-2.4.1/gems/capybara-3.2.1/lib/capybara/session.rb:734:in `block (2 levels) in <class:Session>'
     # /Users/jaror/.rvm/gems/ruby-2.4.1/gems/capybara-3.2.1/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'

After investigation:
Capybara 2.x https://github.com/teamcapybara/capybara/blob/2.17_stable/lib/capybara/node/element.rb

##
      #
      # Set the value of the form element to the given value.
      #
      # @param [String] value    The new value
      # @param [Hash{}] options  Driver specific options for how to set the value
      #
      # @return [Capybara::Node::Element]  The element
      def set(value, options={})
        options ||= {}

        driver_supports_options = (base.method(:set).arity != 1)

        unless options.empty? || driver_supports_options
          warn "Options passed to Capybara::Node#set but the driver doesn't support them"
        end

        synchronize do
          if driver_supports_options
            base.set(value, options)
          else
            base.set(value)
          end
        end
        return self
      end

Now https://github.com/teamcapybara/capybara/blob/master/lib/capybara/node/element.rb

##
      #
      # Set the value of the form element to the given value.
      #
      # @param [String] value    The new value
      # @param [Hash{}] options  Driver specific options for how to set the value. Take default values from {Capybara#default_set_options}
      #
      # @return [Capybara::Node::Element]  The element
      def set(value, **options)
        raise Capybara::ReadOnlyElementError, "Attempt to set readonly element with value: #{value}" if readonly?
        options = session_options.default_set_options.to_h.merge(options)
        synchronize { base.set(value, options) }
        self
      end

So they removed driver_supports_options and always call base.set(value, options)

In appium_capybara is like below https://github.com/appium/appium_capybara/blob/master/lib/appium_capybara/driver/appium/node.rb

# Override
    def set(value)
      native.clear
      send_keys(value)
    end

Appium driver and node inheritance should be consistent

This is what the change would look like to make Appium's node inherit from Selenium's node in Capybara.
96c72dd

The methods that are the same in Appium have been removed, however some methods such as "set" are overridden entirely. This means that if you tried to use the Appium node for some web automation, you will sometimes get different behavior. Is this ok? Should we switch back to inheriting both driver and node from base?
Thoughts? @bootstraponline @randoum

W3C actions sends wrong action id

This is a

  • Bug report
  • Question
  • Feature Request

Summary

Environment

  • iOS12 iPhone 8
  • iOS12 iPhone 11
  • iOS13 iPhone 11

Actual behaviour and steps to reproduce

element.send_keys([:shift, :end])

Expected behaviour

ArgumentError, "You cannot send multiple keystrokes simultaneously to a mobile driven device"

Actual behaviour

An unknown server-side error occurred while processing the command. Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Only actions of '(
    pointer,  key
)' types are supported. 'key' is given instead for action with id 'keyboard'" UserInfo={NSLocalizedDescription=Only actions of '(
    pointer,  key
)' types are supported. 'key' is given instead for action with id 'keyboard'} (Selenium::WebDriver::Error::UnknownError)

UnknownError: An unknown server-side error occurred while processing the command. Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Only actions of '(
    pointer,  key
)' types are supported. 'key' is given instead for action with id 'keyboard'" UserInfo={NSLocalizedDescription=Only actions of '(
    pointer, key
)' types are supported. 'key' is given instead for action with id 'keyboard'}
    at errorFromW3CJsonCode (/usr/local/.browserstack/appium_1.17.0_bstack/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)
    at ProxyRequestError.getActualError (/usr/local/.browserstack/appium_1.17.0_bstack/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)
    at JWProxy.command (/usr/local/.browserstack/appium_1.17.0_bstack/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:265:8)

Any additional comments

Maybe some more documentation would be good on this note.

Issue with Capybara 3.19+?

Hello,

I tried to update my test suite to a newer version of Capybara and things didn't turn as expected:

.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/appium_capybara-1.7.0/lib/appium_capybara/ext/selector_ext.rb:12:in `block in <top (required)>': undefined method `custom' for #<Capybara::Selector::Definition:0x00007fc3c1728300> (NoMethodError)

The issue disappears when downgrading Capybara to 3.18.

I see "Failure/Error: if e = error()" error while running my TC for android using Ruby + Capybara + Appium + Rspec

Environment:
Appium version: 1.4.16.1
Desktop OS/version used to run Appium: Windows 7
Samsung Galaxy S6 - real device

Details
I am trying to set up environment for mobile automation TC running. I use Ruby + Capybara + Appium + Rspec. But something went wrong. I see errors while run TC

Logs:
https://gist.github.com/kay4444/50f4ece611acbd4bb0b4713e2b7f57ef
My settings file:
https://gist.github.com/kay4444/0e903c1368e14ffb055300661a6a4331
My TC file:
https://gist.github.com/kay4444/1a8ef7f9fca011882cf8a0392521abbd
My Gem file:
https://gist.github.com/kay4444/34e1616eb9463c5d79d8b3ee74e7baa2

Getting 'NoMethodError: undefined method `to_sym' for nil:NilClass' error when using Capybara+SitePrism+Appium+Rspec

Currently can not run tests that were previously working (10 days ago). When app is installed and invoked it is failing immediately with the error mentioned below on the line '@app.startup.start_button.click`

Environment

  • Mac, rspec 3.8 , capybara 3.18, site_prism 3.2 (versions 3.1 and 3.0 also gave the same error)
  • Rspec as framework

I get the following error:

NoMethodError: undefined method to_sym' for nil:NilClass`

Spec_helper:

    config.before(:example) do |example|
    @app ||= App.new
    @app.startup.start_button.click

Page:

class StartupPage < SitePrism::Page
    element :start_button, :id, 'start'
  end

App.page:

current_path = File.expand_path('..', __FILE__)
$LOAD_PATH.unshift File.join(current_path)

Dir.glob(File.join(current_path, '**', '*.rb')).each do |f|
  require f
end
class App
  def initialize
    @pages = {}
  end
  def startup
    @pages[:startup] ||= StartupPage.new
  end
end

Unanted additional session at the end of the test suite

I can't tell if the issue is coming from appium, from appium_capybara, or from selendroid

At the end of the test suite, which is all green, the app in the emulator closes and reopen. I checked appium log and there is a strange Resetting app mid-session which come just after my last assertion, followed by re-installing and re-starting the app.

Note that I have in my spec_helper and after :suite block that closes Appium driver. I tried with and without that block and the issue is the same

Log (starting at my last assertion):

debug: Proxying command to localhost:8080
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/f6ee70cd-9355-76d0-5495-42a57f594220/element/:wdc:1407460168895/text","method":"GET"}
debug: Proxied response received with status 200: "{\"value\":\"Je souhaites creer un compte.\",\"status\":0,\"sessionId\":\"f6ee70cd-9355-76d0-5495-42a57f594220\"}"
info: <-- GET /wd/hub/session/f6ee70cd-9355-76d0-5495-42a57f594220/element/:wdc:1407460168895/text 200 139.051 ms - 103 
info: --> POST /wd/hub/session/f6ee70cd-9355-76d0-5495-42a57f594220/appium/app/reset {}
debug: Resetting app mid-session
debug: Running generic full reset
info: Shutting down appium session
debug: Stopping selendroid server
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/f6ee70cd-9355-76d0-5495-42a57f594220","method":"DELETE"}
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "am force-stop com.rhomobile.myapp"
debug: Stopping logcat capture
debug: Logcat terminated with code null, signal SIGTERM
debug: Cleaning up appium session
debug: Restarting app
debug: No appActivity desired capability or server param. Parsing from apk.
debug: No appPackage desired capability or server param. Parsing from apk.
debug: Using local app from desired caps: /workspace/my_app/bin/target/android/MyApp-debug.apk
debug: Creating new appium session 413e0ac7-d863-47d5-8009-8b076a72040f
debug: Starting selendroid server
debug: Checking whether selendroid is built yet
debug: Selendroid server exists!
debug: Preparing device for session
debug: Checking whether app is actually present
debug: Checking whether adb is present
debug: Using adb from /opt/android-sdk-linux/platform-tools/adb
info: Retrieving device
debug: Trying to find a connected android device
debug: Getting connected devices...
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" devices
debug: 1 device(s) connected
info: Found device emulator-5554
debug: Setting device id to emulator-5554
debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 wait-for-device
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "echo 'ready'"
debug: Starting logcat capture
debug: Checking whether aapt is present
debug: Using aapt from /opt/android-sdk-linux/build-tools/19.1.0/aapt
debug: hasInternetPermissionFromManifest: "/opt/android-sdk-linux/build-tools/19.1.0/aapt" dump badging /workspace/my_app/bin/target/android/MyApp-debug.apk
debug: Parsing package and activity from app manifest
debug: Checking whether aapt is present
debug: Using aapt from /opt/android-sdk-linux/build-tools/19.1.0/aapt
debug: packageAndLaunchActivityFromManifest: "/opt/android-sdk-linux/build-tools/19.1.0/aapt" dump badging /workspace/my_app/bin/target/android/MyApp-debug.apk
debug: badging package: com.rhomobile.myapp
debug: badging act: com.rhomobile.rhodes.RhodesActivity
debug: Parsed package and activity are: com.rhomobile.myapp/com.rhomobile.rhodes.RhodesActivity
debug: Rebuilt selendroid server already exists, no need to rebuild it with a new manifest
debug: Checking signed status of /tmp/selendroid.com.rhomobile.myapp.apk
debug: Checking app cert for /tmp/selendroid.com.rhomobile.myapp.apk: java -jar "/.npm/lib/node_modules/appium/node_modules/appium-adb/jars/verify.jar" "/tmp/selendroid.com.rhomobile.myapp.apk"
debug: Checking signed status of /workspace/my_app/bin/target/android/MyApp-debug.apk
debug: Checking app cert for /workspace/my_app/bin/target/android/MyApp-debug.apk: java -jar "/.npm/lib/node_modules/appium/node_modules/appium-adb/jars/verify.jar" "/workspace/my_app/bin/target/android/MyApp-debug.apk"
debug: App already signed.
debug: Zip-aligning /tmp/selendroid.com.rhomobile.myapp.apk
debug: Checking whether zipalign is present
debug: Using zipalign from /opt/android-sdk-linux/build-tools/19.1.0/zipalign
debug: zipAlignApk: "/opt/android-sdk-linux/build-tools/19.1.0/zipalign" -f 4 "/tmp/selendroid.com.rhomobile.myapp.apk" "/tmp/appium11478-19033-iejuaa.tmp"
debug: App already signed.
debug: Zip-aligning /workspace/my_app/bin/target/android/MyApp-debug.apk
debug: Checking whether zipalign is present
debug: Using zipalign from /opt/android-sdk-linux/build-tools/19.1.0/zipalign
debug: zipAlignApk: "/opt/android-sdk-linux/build-tools/19.1.0/zipalign" -f 4 "/workspace/my_app/bin/target/android/MyApp-debug.apk" "/tmp/appium11478-19033-u4uq6l.tmp"
debug: Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
debug: Uninstalling com.rhomobile.myapp.selendroid
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "am force-stop com.rhomobile.myapp.selendroid"
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 uninstall com.rhomobile.myapp.selendroid
debug: App was uninstalled
debug: Getting install status for com.rhomobile.myapp.selendroid
debug: Getting device API level
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "getprop ro.build.version.sdk"
debug: Device is at API Level 19
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "pm list packages -3 com.rhomobile.myapp.selendroid"
debug: App is not installed
debug: Rebuilt selendroid is not installed, installing it
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 install -r "/tmp/selendroid.com.rhomobile.myapp.apk"
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "getprop persist.sys.language"
debug: Current device language: en
debug: java -jar "/.npm/lib/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar" "stringsFromApk" "/workspace/my_app/bin/target/android/MyApp-debug.apk" "/tmp/com.rhomobile.myapp" en
debug: No strings.xml for language 'en', getting default strings.xml
debug: java -jar "/.npm/lib/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar" "stringsFromApk" "/workspace/my_app/bin/target/android/MyApp-debug.apk" "/tmp/com.rhomobile.myapp"
debug: Not uninstalling app since server not started with --full-reset
debug: Checking app cert for /workspace/my_app/bin/target/android/MyApp-debug.apk: java -jar "/.npm/lib/node_modules/appium/node_modules/appium-adb/jars/verify.jar" "/workspace/my_app/bin/target/android/MyApp-debug.apk"
debug: App already signed.
debug: Zip-aligning /workspace/my_app/bin/target/android/MyApp-debug.apk
debug: Checking whether zipalign is present
debug: Using zipalign from /opt/android-sdk-linux/build-tools/19.1.0/zipalign
debug: zipAlignApk: "/opt/android-sdk-linux/build-tools/19.1.0/zipalign" -f 4 "/workspace/my_app/bin/target/android/MyApp-debug.apk" "/tmp/appium11478-19033-28nm25.tmp"
debug: MD5 for app is a15e6b2fbbceb96451b0bc5c58373c0f
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "ls /data/local/tmp/a15e6b2fbbceb96451b0bc5c58373c0f.apk"
debug: Getting install status for com.rhomobile.myapp
debug: Getting device API level
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "getprop ro.build.version.sdk"
debug: Device is at API Level 19
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "pm list packages -3 com.rhomobile.myapp"
debug: App is installed
info: App is already installed, resetting app
debug: Running fast reset (stop and clear)
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "am force-stop com.rhomobile.myapp"
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "pm clear com.rhomobile.myapp"
debug: Forwarding system:8080 to device:8080
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 forward tcp:8080 tcp:8080
debug: Pushing settings apk to device...
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 install "/.npm/lib/node_modules/appium/build/settings_apk/settings_apk-debug.apk"
debug: Pushing unlock helper app to device...
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 install "/.npm/lib/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk"
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "dumpsys window"
debug: Writing dumpsys output to /.npm/lib/node_modules/appium/.dumpsys.log
debug: Screen already unlocked, continuing.
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "am instrument -e main_activity 'com.rhomobile.rhodes.RhodesActivity' com.rhomobile.myapp.selendroid/io.selendroid.ServerInstrumentation"
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
debug: Selendroid server is alive!
debug: Listening for Selendroid logs
debug: Creating Selendroid session
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session","method":"POST","json":{"desiredCapabilities":{"warnings":{},"desired":{"platformName":"android","deviceName":"Android Emulator","automationName":"selendroid","app":"/workspace/my_app/bin/target/android/MyApp-debug.apk"},"platformName":"android","deviceName":"Android Emulator","automationName":"selendroid","app":"/workspace/my_app/bin/target/android/MyApp-debug.apk"}}}
debug: Successfully started selendroid session
debug: Waiting for pkg "com.rhomobile.myapp" and activity "com.rhomobile.rhodes.RhodesActivity" to be focused
debug: Getting focused package and activity
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "dumpsys window windows"
debug: [SELENDROID] http://localhost:8080/wd/hub/session/b40202ed-ce8b-3da8-169b-a634a662d659
debug: Overriding session id with "b40202ed-ce8b-3da8-169b-a634a662d659"
debug: Device launched! Ready for commands
debug: Setting command timeout to the default of 60 secs
debug: Setting command timeout to 60 secs
debug: Responding to client with success: {"status":0,"value":60,"sessionId":"f6ee70cd-9355-76d0-5495-42a57f594220"}
info: <-- POST /wd/hub/session/f6ee70cd-9355-76d0-5495-42a57f594220/appium/app/reset 200 32742.524 ms - 74 {"status":0,"value":60,"sessionId":"f6ee70cd-9355-76d0-5495-42a57f594220"}
info: --> DELETE /wd/hub/session/f6ee70cd-9355-76d0-5495-42a57f594220 {}
info: Shutting down appium session
debug: Stopping selendroid server
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/b40202ed-ce8b-3da8-169b-a634a662d659","method":"DELETE"}
debug: executing: "/opt/android-sdk-linux/platform-tools/adb" -s emulator-5554 shell "am force-stop com.rhomobile.myapp"
debug: Stopping logcat capture
debug: Logcat terminated with code null, signal SIGTERM
debug: Cleaning up appium session
debug: Responding to client with success: {"status":0,"value":null,"sessionId":"f6ee70cd-9355-76d0-5495-42a57f594220"}
info: <-- DELETE /wd/hub/session/f6ee70cd-9355-76d0-5495-42a57f594220 200 2964.928 ms - 76 {"status":0,"value":null,"sessionId":"f6ee70cd-9355-76d0-5495-42a57f594220"}

My spec_helper, if you are interested

require 'rubygems'

$android_driver_loaded = false
ENV['RAILS_ENV'] ||= 'test'

# Load rails + environment
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'

# Load matchers/helpers
require 'shoulda-matchers'
require 'rspec-html-matchers'
require 'json_spec'

# Load database cleaner
require 'database_cleaner'

# Load capybara and its dependencies
require 'capybara/rspec'
require 'capybara/rails'
require 'selenium-webdriver'
require 'headless'

Capybara.server_host = '0.0.0.0'
Capybara.server_port = 56844

# Load carrierwave helpers
require 'carrierwave/test/matchers'

# Needed by elasticsearch
require 'rake'


RSpec.configure do |config|
  # When present, test with :focus tag will be tested alone
  #config.filter_run :focus => true

  # Spec mock
  config.mock_with(:rspec) { |c| c.syntax = [:should, :expect] }

  # Includes FactoryGirl syntax
  config.include FactoryGirl::Syntax::Methods

  # Include JsonSpec helpers
  config.include JsonSpec::Helpers

  # Include carrierwave helpers
  config.include CarrierWave::Test::Matchers

  # Do not use transactional, let database_cleaner do the work
  config.use_transactional_fixtures = false

  # Anonymous controller
  config.infer_base_class_for_anonymous_controllers = true

  # Run specs in random order. Can fix the order by providing the seed: --seed 1234
  config.order = 'random'

  # Log example name before running it
  # config.before(:each) do |x|
  #   Rails.logger.debug '============================================='
  #   Rails.logger.debug x.example.metadata[:example_group][:full_description]
  # end

  # Cache test config
  config.before(:each, cache: true) { Rails.cache.clear }
  config.before(:each, type: :feature) { Rails.cache.clear }

  # CarrierWave test config
  config.before(:each) { CarrierWave.configure { |c| c.enable_processing = false } }
  config.after(:suite) { FileUtils.rm_rf Dir.glob('public/test/*') }

  # Mailer test config
  config.before(:each, mailer: true) { ActionMailer::Base.deliveries.clear }

  # Sidekiq test config
  config.before(:each, sidekiq: true) { Sidekiq::Worker.clear_all }

  # Elasticsearch test config
  config.before(:each, elasticsearch: true) { before_test_initialize_elasticsearch Product }
  config.after(:each, elasticsearch: true) { after_test_clean_elasticsearch Product }

  # Database cleaner config
  config.before(:suite) { DatabaseCleaner.clean_with :truncation }
  config.before(:each) { DatabaseCleaner.strategy = :transaction }
  config.before(:each, js: true) { DatabaseCleaner.strategy = :truncation }
  config.before(:each, android: true) { DatabaseCleaner.strategy = :truncation }
  config.before(:each, truncation: true) { DatabaseCleaner.strategy = :truncation }

  config.before(:each) { DatabaseCleaner.start }
  config.after(:each) { DatabaseCleaner.clean }

  # HAML helpers
  config.include Haml
  config.include Haml::Helpers
  config.before(:each, type: :view) { init_haml_helpers }

  # Headless for selenium driver
  config.before(:suite) { Headless.new(display: (99 +  ENV['TEST_ENV_NUMBER'].to_i), destroy_at_exit: false).start }
  config.after(:suite) { Headless.new(display: (99 +  ENV['TEST_ENV_NUMBER'].to_i), reuse: true).destroy }

  # Android driver
  config.before(:each, android: true) {
    # Load appium, and create driver
    require 'appium_capybara'

    Capybara.register_driver :android do |app|
      options = {
          start_capybara_server: true,
          appium_lib:{
              server_url: 'http://localhost:4723/wd/hub' },
          caps: {
              platformName:   :android,
              deviceName:     'Android Emulator',
              automationName: 'selendroid',
              app:            '/workspace/my_app/bin/target/android/MyApp-debug.apk' } }
      Appium::Capybara::Driver.new app, options
    end

    # Set capybara
    Capybara.default_driver = :android
    Capybara.default_wait_time = 30

    $android_driver_loaded = true
  }
  config.after(:suite) { Capybara.current_session.driver.browser.driver_quit if $android_driver_loaded }
end

# Load factories
FactoryGirl.reload

# Load custom matchers and macros, etc
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }

appium_driver.start_driver times out

OSX 10.9.5
Emulator running Android 4.3.1
Appium 1.4.6

the following ruby code in irb

require 'selenium-webdriver'
require 'appium_lib'


 desired_caps = {
   caps:  {
        platformName:  'Android',
        platformVersion: '4.3.1',
        deviceName:    'jelly-bean',
        browserName:   'Browser',
    }
}

@appium_driver = Appium::Driver.new(desired_caps) 

@selenium_driver = @appium_driver.start_driver 

time out on the last line

Selenium::WebDriver::Error::WebDriverError: An operation did not complete before its timeout expired. (Original error: timeout: Adb command timed out after 30 seconds
(Driver info: chromedriver=2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961),platform=Mac OS X 10.9.5 x86_64))

tail of the appium console:

  info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data","status":0}
  info: Chromedriver: Set chromedriver binary as: /Users/greena28/Downloads/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver
  info: Chromedriver: Killing any old chromedrivers, running: ps -ef | grep /Users/greena28/Downloads/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver | grep -v grep |grep -e '--port=9515\(\s.*\)\?$' | awk '{ print $2 }' | xargs kill -15
  info: Chromedriver: Successfully cleaned up old chromedrivers
  info: Chromedriver: Spawning chromedriver with: /Users/greena28/Downloads/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver --url-base=wd/hub --port=9515
  info: Chromedriver: [STDOUT] Starting ChromeDriver 2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961) on port 9515
  Only local connections are allowed.
  info: JSONWP Proxy: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
  info: JSONWP Proxy: Got response with status 200: {"sessionId":"","status":0,"value":{"build":{"version":"alpha"},"os":{"arch":"x86_64","name":"Mac OS X","version":"10.9.5"}}}
  info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.browser","androidActivity":"com.android.browser.BrowserActivity","androidDeviceSerial":"emulator-5554"}}}
  info: JSONWP Proxy: Got response with status 200: {"sessionId":"3d688fcc95fe243ddc4a6cb7b3db3111","status":21,"value":{"message":"timeout: Adb command timed out after 30 seconds\n  (Driver info: chromedriver=2.16.333243 (0bfa1d3575fc1044244f21ddb82bf...
  info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.browser","androidActivity":"com.android.browser.BrowserActivity","androidDeviceSerial":"emulator-5554"}}}
  info: JSONWP Proxy: Got response with status 200: {"sessionId":"eebe17ea9be3c7f28a57619c3da50042","status":21,"value":{"message":"timeout: Adb command timed out after 30 seconds\n  (Driver info: chromedriver=2.16.333243 (0bfa1d3575fc1044244f21ddb82bf...
  info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.browser","androidActivity":"com.android.browser.BrowserActivity","androidDeviceSerial":"emulator-5554"}}}

The browser launches in the emulator but that information does not appear to be making it back to the console

wrong number of arguments (given 1, expected 0), when connect to sauce session

Code:
Capybara.current_session.driver.browser.manage.window.maximize

getting error of wrong argument when connect to sauce. It is working fine at local execution.

Started getting this error when I have upgrade the ruby version from Ruby 2.3 to Ruby 3.0. Using selenium version 3.142.7 in sauce capabilities. Please guide me.

Update run time dependency for latest version of capybara

Is it possible to add_runtime_dependency for the latest version of capybara?
https://github.com/teamcapybara/capybara/releases

I use capybara and appium_capybara, but I could not bump up my version of capybara to ~> 3.0 since it conflicts with the dependency for appium_capybara.

Bundler could not find compatible versions for gem "capybara":
  In Gemfile:
    capybara (~> 3.0.3)

    appium_capybara was resolved to 1.4.1, which depends on
      capybara (~> 2.7)

Ambiguous match error on sample

  1) UICatalog smoke test should detect the nav bar
     Failure/Error: expect(@home_page.navigation_bar.displayed?).to be_truthy
     Capybara::Ambiguous:
       Ambiguous match, found 2 elements matching name "UICatalog"
     # ./spec/ios_example_spec.rb:14:in `block (2 levels) in <top (required)>'

Cant use hide_keyboard on Android native app

In my test i need to use hide_keyboard method but seems like it does not work with appium capybara. There is an appium method @driver.hide_keyboard so in my case i am using it this way:

Capybara.current_session.driver.hide_keyboard

However it gives error

NoMethodError: undefined method 'hide_keyboard' for #<Appium::Capybara::Driver:0x00007fe5ab0914e0>

  0) My Account tests Verify user can be created successfully and then login
     Failure/Error: Capybara.current_session.driver.hide_keyboard

     NoMethodError:
       undefined method `hide_keyboard' for #<Appium::Capybara::Driver:0x00007fe5ab0914e0>

Appium logs can be found here:
https://gist.github.com/AlonaPF/8178fc74dbe3cba94de810b98c22f635

Selenium::WebDriver::Error::InvalidElementStateError: Cannot set the element to 'abc'. Did you interact with the correct element?

I am using rspec framework for mobile automation testing. There I use appium_capybara along with appium_lib.

When I am trying to set any value in the text box, it throws an exception:
Selenium::WebDriver::Error::InvalidElementStateError: Cannot set the element to 'abc'. Did you interact with the correct element?

My code is:
$capy_driver = Capybara.current_session.driver
$capy_driver.find_custom(:xpath, "//android.widget.ImageView[@text='Email Address']")[0].send_keys 'abc'

Here click is working, but when I use send key then it throws exception.

Thanks
Vidhi

Documentation: Is there any?

I do not understand the use of this gem but certainly, I would like.

I do not know how to use all the features inside this project. Could you provide decent documentation?

Thank you!

NotImplementedError: NotImplementedError

Can't tell if it's related to #3

At the end of my specs I got NotImplementedError: NotImplementedError. Seems to be coming from the call of assert_no_selector in Capybara::Session.reset!

Here is the trace, tell me if you need more detail.
Thanks

NotImplementedError: NotImplementedError
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/driver/node.rb:16:in `visible_text'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/node/element.rb:61:in `block in text'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/node/base.rb:80:in `synchronize'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/node/element.rb:57:in `text'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/result.rb:42:in `map'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/result.rb:42:in `failure_message'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/result.rb:54:in `negative_failure_message'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/node/matchers.rb:125:in `block in assert_no_selector'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/node/base.rb:84:in `synchronize'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/node/matchers.rb:121:in `assert_no_selector'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/session.rb:675:in `block (2 levels) in <class:Session>'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/appium_capybara-0.0.2/lib/appium_capybara/ext/session_ext.rb:7:in `reset!'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara.rb:257:in `block in reset_sessions!'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara.rb:257:in `each'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara.rb:257:in `reset_sessions!'
/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.4.1/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>'
# Skipped 32 lines of call to rspec-core

Appium Capybara not supporting native Capybara web methods

Hello All,

I have written Capybara script for web and now trying to run same script on mobile using the Appium Capybara lib, it does support most of the methods but still faces issues with below method

page.first(:link, link_text).click

I am getting below error after running the scipt

undefined methodclick' for nil:NilClass (NoMethodError)
`

Unnecessary relaunching of IOS simulator when calling Capybara::Session#reset! in session_ext.rb

I'm running a bunch of rspec tests that use capybara to test a web-product.
So I found this library here to target appium. I use appium so I can test our web-product on IOS devices. Either in the IOS simulator, or on a real IOS device.

Anyways, when I run one rspec example, like this:

example "Dummy test" do
  visit "/author/surveys/#{jedi.id}"
end

So after the example is done, and my local config(:after) blocks are run, I expect the IOS simulator to be left as is.
Nope.

After everything is done, a call to reset the sessions occurs. In my case, the IOS simulator is then completely closed, and then relaunches itself again. In other words a completely useless call, since the safari browser is already reset. This takes a freaking long time, and thus my rspec test that takes 3.4 seconds on chrome, takes 34 to 40 seconds on IOS.

Using Capybara 2.4.4 the call to reset the sessions occurs here:
../gems/capybara-2.4.4/lib/capybara/rspec.rb

config.after do
  if self.class.include?(Capybara::DSL)
    Capybara.reset_sessions!

Which eventually reaches here:
../gems/appium_capybara-1.2.1/lib/appium_capybara/ext/session_ext.rb

module Capybara
  class Session
    def reset!
      # Work around for issue https://github.com/jnicklas/capybara/issues/1237
      browser_initialized = driver.respond_to?(:browser_initialized?) ? driver.browser_initialized? : true

      if @touched && browser_initialized
        driver.reset!

Which then goes thru here:
../gems/appium_capybara-1.2.1/lib/appium_capybara/driver/appium/driver.rb

# override
def reset!
  # invoking the browser method after the browser has closed will cause it to relaunch
  # use @appium_driver to avoid the relaunch.
  @appium_driver.reset if @appium_driver
end

So I'd like to know how can I prevent the IOS simulator from constantly relaunching between rspec examples? It's slowing down my test runs by about a 1000%

Gesture cannot be processed correctly

Good day,

We use appium, capybara, and this gem to test iOS application. The problem is that we can't use gestures (touch action especially) in our tests. We tried to perform it like this:

current_driver = Capybara.current_session.driver
Appium::TouchAction.new(current_driver).tap(x: 45, y: 110, duration: 1000).release.perform

But we got this error:

NoMethodError:
       undefined method `touch_actions' for #<Appium::Capybara::Driver:0x007f8575e1a760>

Do you have any other options to fire this action on?

More details about initialization:

Nothing really specific. We initialize driver like this:

# options is a hash of capabilities.
options = {
  caps: {
    platformName: 'ios',
    deviceName: 'iPhone X',
    platformVersion: '11.0',
    automationName: 'XCUITest',
    app: path_to_app
  }
}
Capybara.register_driver(:appium_ios) do |app|
    Appium::Capybara::Driver.new(app, options)
end

Capybara.default_driver = :appium_ios

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.