kif-framework / KIF

Keep It Functional - An iOS Functional Testing Framework
Other
6.21k stars 913 forks source link

How to programmatically tap the "Cancel" button of a UISearchBar? #548

Closed dlo closed 6 years ago

dlo commented 9 years ago

Hi all. First of all, thanks for your hard work on KIF. This library has been a godsend. :P

I'm trying to programmatically tap the "Cancel" button of a UISearchBar. I've tried cycling through its subviews to no avail, and hardcoding a point to tap just seems wrong. Is there a suggested / correct way to do this? Thanks!

danielgomezrico commented 9 years ago

If you tap view with accessibility label "Cancel" it works?

dlo commented 9 years ago

Unfortunately, that does not work.

image

danielgomezrico commented 9 years ago
  1. what are you doing to see the error like XCTest? I get the KIF errors (like that) only in terminal...

hmm

dlo commented 9 years ago

I get them in the terminal too, but figured it'd be easier to understand what I'm seeing with this output.

danielgomezrico commented 9 years ago

but I don't get the errors in xcode, just in terminal, how can I enable that?

dlo commented 9 years ago

Not totally sure what your setup is...for me they show up automatically.

danielgomezrico commented 9 years ago

I'm using swift so maybe is because of that:

extension XCTestCase {

    var tester: KIFUITestActor { return tester() }

    func tester(_ file : String = __FILE__, _ line : Int = __LINE__) -> KIFUITestActor {
        return KIFUITestActor(inFile: file, atLine: line, delegate: self)
    }

    func system(_ file : String = __FILE__, _ line : Int = __LINE__) -> KIFSystemTestActor {
        return KIFSystemTestActor(inFile: file, atLine: line, delegate: self)
    }

}

It shows the error in tester(_ file...) -> KIFUITestActor return

phatmann commented 9 years ago

Can you turn on the Accessibility Inspector in the simulator and see what the Cancel button's label is?

danielgomezrico commented 6 years ago

Sorry, I lost code access to that repo, but thanks for answering back then. :)