setting up tests to run with Capybara on android device connected locally

551 views
Skip to first unread message

George Speake

unread,
Mar 13, 2014, 4:56:25 PM3/13/14
to appium-...@googlegroups.com
appium server running. chrome starts up and test attempts to navigate to 127.0.0.1:62918 but page can't be found because the rails app that is normally started by Capybara when testing on the desktop browser does not live on the android device. what am i missing?


    Capybara.register_driver :android_device do |app|
      caps = {:device => "Android", :app => 'chrome'}
      Capybara::Selenium::Driver.new(app, {:browser => :remote, :url => "http://localhost:4723/wd/hub", :desired_capabilities => caps})
    end
    Capybara.default_driver = :android_device


if i do a simple test like this, it works...


   caps = {:device => "Android", :app => 'chrome'}

   driver = Selenium::WebDriver.for :remote, :url => "http://localhost:4723/wd/hub", :desired_capabilities => caps


   element = driver.find_element(:name, 'q')
   element.send_keys "Hello WebDriver!"
   element.submit

   puts driver.title
   driver.quit


thanks.

Jonathan Lipps

unread,
Mar 13, 2014, 6:11:09 PM3/13/14
to George Speake, appium-...@googlegroups.com
android localhost is not the same as system localhost. to get to system localhost on android, use 10.0.2.2 instead of 127.0.0.1

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/d/optout.

George Speake

unread,
Mar 13, 2014, 7:23:47 PM3/13/14
to appium-...@googlegroups.com
 " use 10.0.2.2 instead of 127.0.0.1" does this mean i can change this in the Capybara::DSL? or that i can't use Capybara::DSL? 

or maybe i just don't understand.

Jonathan Lipps

unread,
Mar 13, 2014, 10:06:09 PM3/13/14
to George Speake, appium-...@googlegroups.com
I mean that instead of attempting to navigate to 127.0.0.1:62918 you should try to navigate to 10.0.2.2:62918 for tests running in chrome on android. Not sure how you make your test change what it navigates to, that'd be a ruby/capybara question.

Reply all
Reply to author
Forward
0 new messages