Automating Hybrid App Testing

I have been trying to automate hybrid app using Ruby bindings

UI Flow is like this
Screen 1 -> Native View Containing Login buttons(Google)
Screen 2 -> Native Elements + UIWebView that contains buttons(Allow, Deny)
Screen 3 -> Native View

Here is the skeleton code
a) wait{find_element(:xpath,"//UIAButton[@name='Google'").click} b) wait.until{find_element(:xpath, "//UIAButton[@name='Allow'").displayed?} c) wait.until{find_element(:xpath, "//UIAButton[@name='Allow'").click}
I noticed ‘b’ always fails although I can see the button on the device.

With arc, following things happen

  1. pry>find_element(:xpath, “//UIAButton[@name=‘Allow’”).displayed?
  2. pry> false
  3. pry>find_element(:xpath, “//UIAButton[@name=‘Allow’”).click ## Failed
  4. pry> nil
  5. pry>find_element(:xpath, “//UIAButton[@name=‘Allow’”)
  6. pry># Selenium::WebDriver::Element:0x…fcb24f281c63578c6 id=“17”
  7. pry>find_element(:xpath, “//UIAButton[@name=‘Allow’”).click ## Passed
  8. pry>nil

I would like to understand what is happening between steps 3 to 8. (Is Appium changing contexts transparently etc…) –

  • where initially step 3 failed even though button was visible
  • Then after executing step 5, I am able to click button as done in step 7

Also would like to get suggestions on improving ruby code to incorporate the changes