These are chat archives for appium/ruby_lib

5th
Apr 2017
Hardik Desai
@hardik-d
Apr 05 2017 05:57
hmm so not a system alert but a pop up
did you try without switching?
just wait for alert element to show and then accessing the element?
if that does not work show me a SS of the alert
Evangeline Ireland
@eireland
Apr 05 2017 17:23
blob
Can't not switch to alert as can't get to the element. I'm attaching a screenshot.
Hardik Desai
@hardik-d
Apr 05 2017 18:51
you should be able to get to native_context and click on the ok button or the text for your validations
but my question was show me the code that is failing
Evangeline Ireland
@eireland
Apr 05 2017 20:09

The main code has

alert = $test.switch_to_alert
puts "before accept alert #{alert}"
alert.accept if alert
puts "after accept alert #{alert}"
$test.save_screenshot

with switch_to_alert looks like:

def switch_to_alert(timeout = 300)
    sleep_time = 0.5
    start_time = Time.now
    alert = nil
    loop do
      puts "in loop before switch"
      alert = @driver.switch_to.alert rescue nil
      break unless alert.nil? && Time.now - start_time < timeout
      sleep(sleep_time)
    end
    puts "in loop after switch"
    alert
  end
I know it's not making it to the after accept console log.
Hardik Desai
@hardik-d
Apr 05 2017 20:46
right, so i have been trying to tell you ignore having to switch_to_alert
Hardik Desai
@hardik-d
Apr 05 2017 20:55
and wait for ok button to be displayed
and then click on it
Evangeline Ireland
@eireland
Apr 05 2017 22:22
Solved it by changing Android emulator to a newer version so I can run Chrome instead of Browser.