xcode - How do i read text from an Alert(ios) in calabash -


how can access text of alertview on ios in calabash/cucumber tests?

nsstring *msgstring = [nsstring stringwithformat:@"no: %@\n latitude: %f\n longitude: %f", wrapper.no, wrapper.latitude, wrapper.longitude]; uialertview *alert = [[[uialertview alloc] initwithtitle:@"really reset?" message:@"msgstring" delegate:self cancelbuttontitle:@"cancel" otherbuttontitles:nil] autorelease]; // optional - add more buttons: [alert addbuttonwithtitle:@"yes"]; [alert show]; 

i want assert alert has expected content:

feature: running test   user using phone connected internet   want have correct sample data retrieved cache or net   can read values of tableview     scenario: testing retrieved data    given app running   press "refresh"   should see "some value"   press "some value"   should /*see alert "mymessage"*/   press "ok"    , take picture 

so if change string "no:" , discard else string, seem work, cant running more complex string :(

i tested code , working fine

inside step definition file (projectname/features/step_definitions/my_first_steps.rb) add

then /^i see alert "([^\"]*)" text$/ |message|     result = query("view:'uialertview' label text:'#{message}'").empty?     if result         screenshot_and_raise "could not find text field alertview text '#{message}'"     end     sleep(step_pause) end 

and in feature file

then see alert "email cannot empty." text 

if text doesn't match message take screenshot , fails test

but working custom alerts not on system alerts..!!

this if need read message alert

open $ calabash-ios console ,

query query("view:'uialertview'",:message)

add more....

or can use

then /^i wait until alert text "([^\"]*)" , press "([^\"]*)" button$/ |message, button|    wait_for_elements_exist(["alertview child label marked:'#{message}'"], :timeout => 30,  :retry_frequency => 0.3,:timeout_message => "timed out waiting..",:screenshot_on_error => true )     if element_exists("alertview child label marked:'#{message}'")       touch("button marked:'#{button}'")       sleep(step_pause)     else       screenshot_and_raise "alert element not found"     end end 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -