Struggling through the tutorial

I am trying to work through the tutorial on http://appium.io/slate/en/tutorial/ios.html?ruby#appium-ruby-console
So far, I think I got the installation done.

This text is not correct in my case: After seeing ---- reset.sh completed successfully ----, you’ll find UICatalog.app at this location: /appium/sample-code/apps/UICatalog/build/Release-iphonesimulator/UICatalog.app

I found the apps as zipped files under ./appium/assets
So I unzipped them and updated the appium.txt accordingly.

Now, I’ve started node . in one window and ran ‘arc’ in another window.
However, arc fails with this reponse
/Users/andreheijstek/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1/lib/selenium/webdriver/remote/response.rb:73:in `assert_ok’: status code 500 (Selenium::WebDriver::Error::ServerError)

Any idea what went wrong and how to fix this?

Alright,
I just went through this tutorial again myself, and I’m able to confirm that this works.
I Assume that you have the latest appium installed successfully.

I went ahead and looked here and found a couple of anomalies. Maybe it’s just me, maybe this helps you.
http://appium.io/slate/en/tutorial/ios.html?rubyhttp://appium.io/slate/en/tutorial/ios.html?ruby#appium-ruby-console

  1. I’m having a tough time running the ./reset.sh --ios --dev command. I filed a ticket here: Problems with running ./reset.sh --dev (Cannot find module 'appium-instruments')

  2. My backup plan is to complie this using the Xcode UI. I’m picking iPhone 5S.

  3. Once the build is successful, it will show up in your Derived Data directory > UICatalog > Build > Products > Debug… > UICatalog.app I’m attaching a screen shot for navigational purposes.
    Eric

  4. You’ll want to copy this into your sample_code ./apps directory.

  5. In the sample code directory, I actually have this added:

[caps]
platformName = "ios"
platformVersion = "9.1"
app = "./apps/UICatalog.app"
deviceName = "iPhone 5s"
  1. I run
    appium &
  2. I run
    arc

Doing the above, I was able to run ARC successfully.

Let me know if you still have errors.
Thanks!

Thanks Eric, all up and running now!

1 Like

When I move on and run some tests, I notice some other issues:

text(‘Buttons, Various uses of UIButton’).click

does not work (also not with the wait). This is easy to fix:

text(‘Buttons’).click

works perfectly

The trick to work with all cells did not work for me.

cell_names = tags(‘UIATableCell’).map { |cell| cell.name }

gives me 12 cells. But there are more cells in my app, which are not visible without scrolling.
The rest of the code works nicely, it clicks through all 12 cells. But obviously does not click the cells out of view.
How should I get the other cells as well?

Hmm ok. A couple of comments, I may be off here.

  1. your text command. I usually use double quotes, not single. Not sure if that matters. That may have skewed your results.
  2. I haven’t used the tags nor the lcell command before. You are using iOS I can tell. I can get the cells offscreen with this logic:
  my_list = {uiautomation: ".scrollViews()[0].tableViews()[0].cells()"}
  my_elements = find_elements(my_list)
  my_items = my_elements.map { |element| element.name }

Hope this helps.

Hi Eric,
Thanks for continuous support!
I pasted the single quotes from the tutorial. But, double quotes make no difference.


It kind of makes sense though, the text on my app does not contain the text ‘various use of UIButton’, so it seems obvious that this text cannot be found.

Your code to get all elements does not work with me.
This is what I get:

[3] pry(main)> my_list = {uiautomation: “.scrollViews()[0].tableViews()[0].cells()”}
{
:uiautomation => “.scrollViews()[0].tableViews()[0].cells()”
}
[4] pry(main)> p my_list
{:uiautomation=>“.scrollViews()[0].tableViews()[0].cells()”}
{
:uiautomation => “.scrollViews()[0].tableViews()[0].cells()”
}
[5] pry(main)> my_elements = find_elements(my_list)

[6] pry(main)> my_items = my_elements.map { |element| element.name }

[7] pry(main)> p my_items

Ah, You are using UI Catalog.
Basically you have a choice of either finding element by uiautomation or xpath. Both have their advantages. UIAutomation is going away in about 6 months so xpath may be useful?

In any case, this should work.

  1. Find the number of elements. This should count items offscreen for iOS.
    find_elements(:xpath, “//UIATableView[1]/UIATableCell”).size

  2. For each count iterate on the elements and find the text entry. Here we get the first one. Use your iteration counter and loop through accordingly.
    find_elements(:xpath, “//UIATableView[1]/UIATableCell/UIAStaticText[1]”).map {|e| e.text}

More info here:

Good luck! Here’s a screen shot that may help