Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Check the Splash Screen displaying or not, after launching the app using calabash #1384

Open
edrum opened this issue Jun 12, 2018 · 4 comments

Comments

@edrum
Copy link

edrum commented Jun 12, 2018

Automating the Test case(splash screen is visible or not & how much time it is displaying) using calabash.
First I'm trying to verify whether the splash screen is displaying or not after launching the app. But i couldn't achieve. Please help me in doing only in calabash-ios or calabash-android

@edrum edrum changed the title Unable to Check the Splash Screen displaying or not, after launching the app Unable to Check the Splash Screen displaying or not, after launching the app using calabash Jun 12, 2018
@zedtux
Copy link

zedtux commented Jun 12, 2018

Hey @edrum,

I had the same issue than you, and I solved it (well for now the CI isn't complaining) today with the following step definition :

Given(/^the app has launched$/) do
  wait_for(timeout: 120) do
    !query('*').empty?
  end

  wait_for(timeout: 120) do
    query("UILabel {text LIKE 'Loading *% (*)…'}").empty?
  end

  wait_for(timeout: 120) do
    query("UILabel marked:'Loading from localhost:8081...'").empty?
  end
end

Give it a try and le me know 😃

@zedtux
Copy link

zedtux commented Jun 13, 2018

I had to improve it a bit as I discovered that sometimes you can have another "Downloading JavaScript bundle" banner, and also I have a loading screen that I need to wait for.

To summarise my app workflow at boot:

  1. React Native splash screen
  2. My app loading screen (loading translations and more)
  3. Login screen

Here is my step that seems to be quite stable :

Given(/^the app has launched with locale (.*)$/) do |locale|
  # Wait for anything on the screen
  wait_for(timeout: 120) { !query('*').empty? }

  # Wait until the "Loading 0% (0/0)…" is gone if present
  loading_query = "UILabel {text LIKE 'Loading *% (*)…'}"
  unless query(loading_query).empty?
    wait_for(timeout: 120) { query(loading_query).empty? }
  end

  # Wait until the "Loading from localhost:8081..." is gone if present
  loading_from_query = "UILabel marked:'Loading from localhost:8081...'"
  unless query(loading_from_query).empty?
    wait_for(timeout: 120) { query(loading_from_query).empty? }
  end

  # Wait until the "Downloading JavaScript bundle 0% (0/0)…" is gone if present
  downloading_query = "UILabel {text LIKE 'Downloading JavaScript bundle *% (*)…'}"
  unless query(downloading_query).empty?
    wait_for(timeout: 120) { query(downloading_query).empty? }
  end

  @locale = locale
  @translations = load_translation_for(locale)
  if @translations.nil?
    screenshot_and_raise("No translations found for locale #{locale}.")
  end

  if @translations[@locale]['screens'].key?('loading')
    if @translations[@locale]['screens']['loading'].key?('title')
      # Wait until the "Loading" screen is gone if present
      loading_screen_title = @translations[@locale]['screens']['loading']['title']
      loading_screen_query = "UINavigationBar marked:'#{loading_screen_title}'"
      unless query(loading_screen_query).empty?
        wait_for(timeout: 120) { query(loading_screen_query).empty? }
      end
    else
      screenshot_and_raise("The #{@locale} translation is missing the " \
                           "'title' key for the loading screen")
    end
  else
    screenshot_and_raise("The #{@locale} translation is missing the 'loading'" \
                         ' key')
  end
end

If it's not clear, feel free to ask 🙂

@edrum
Copy link
Author

edrum commented Jun 14, 2018

Dear @zedtux, Thanks for your Reply.
i think misunderstood somewhere, my point is, if i give send a command - start_test_server_background, until it returns 'nill' the next command is not running. By that time, the splash screen is ending up & navigating to LOGIN screen.

@zedtux
Copy link

zedtux commented Jun 14, 2018

Oh, I maybe better understood.

Then, what I do is not using the start_test_server_background command but put some puts query('*') in the step the app has launched, so that during the boot step (so while start_test_server_background is running), you can get some details about what is on the screen.

Other than that, yeah, you can't inspect the splash screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants