moredip / Frank

Automated acceptance tests for native iOS apps
www.testingwithfrank.com
Apache License 2.0
1.21k stars 237 forks source link

Can not click on button after view animated #270

Open dangluan opened 10 years ago

dangluan commented 10 years ago

Hi everybody! I try to click button after my view controller animated , but it's not working , and this is errors: When I touch on the "menu icon" button after animate # Frank/features/step_definitions/frank_steps.rb:77 frankly_map button marked:'menu icon' touch failed because: encountered error while attempting to perform touch on selected elements View not touched because it would not be the recipient of the touch event - consider FEX_forcedTouch instead (touch recipient: 0x989cef0#UIView) (RuntimeError) ./Frank/features/step_definitions/frank_steps.rb:81:in /^I touch on the "([^\"]*)" button after animate$/' Frank/features/main.feature:213:in 'When I touch on the "menu icon" button after animate'

And this is my custom frank step: When /^I touch on the "([^\"]*)" button after animate$/ do |mark| wait_for_nothing_to_be_animating selector = "button marked:'#{mark}'" if check_element_exists(selector) touch(selector) end end please help me !!!!

madewulf commented 9 years ago

Have you ever found a solution for this?

oradyvan commented 9 years ago

Well, this sometimes happens when you attempt tapping control while it is still part of animation sequence. Try this approach in your step definition:

wait_for_element_to_exist(selector)
wait_for_nothing_to_be_animating
touch(selector)
madewulf commented 9 years ago

Thanks a lot!

That seems to help indeed, the error disappeared, but now, the problem is that I was trying to touch a UITableViewCell, and apparently, it does not work with this code. I would be very grateful for any idea about this.

On Mon, Jan 19, 2015 at 3:02 PM, Oleksiy Radyvanyuk < notifications@github.com> wrote:

Well, this sometimes happens when you attempt tapping control while it is still part of animation sequence. Try this approach in your step definition:

wait_for_element_to_exist(selector) wait_for_nothing_to_be_animating touch(selector)

— Reply to this email directly or view it on GitHub https://github.com/moredip/Frank/issues/270#issuecomment-70495978.

oradyvan commented 9 years ago

Do you have an output in console showing what kind of issue occurs when your scenario is executed?

madewulf commented 9 years ago

The cell is just not pressed, since the action associated just does not happen.

Here is what I wrote: selector = "view:'IPMoreCell' marked:'Account settings'" check_element_exists selector wait_for_element_to_exist selector wait_for_nothing_to_be_animating touch selector

So, the element does exist, but it is not touched in the end.

oradyvan commented 9 years ago

Try change your cell selector to this:

selector = "view:'IPMoreCell' marked:'Account settings' FEX_isVisible"
madewulf commented 9 years ago

Thanks a lot for your help, but with that, I have the following error:

Given I launch the app                  #

Frank/features/step_definitions/launch_steps.rb:5 Then I should be on the Services screen # Frank/features/step_definitions/login_steps.rb:41 When I open the menu # Frank/features/step_definitions/login_steps.rb:45 When I tap on the user settings # Frank/features/step_definitions/login_steps.rb:49 Could not find element matching selector (view:'IPMoreCell' marked:'Account settings' FEX_isVisible) (RSpec::Expectations::ExpectationNotMetError) ./Frank/features/step_definitions/login_steps.rb:51:in /^I tap on the user settings$/' Frank/features/login.feature:11:inWhen I tap on the user settings' When I logout # Frank/features/step_definitions/login_steps.rb:58

Athought the selector seems ok as you can see in this symbiote screenshot:

https://www.dropbox.com/s/7amz0u96shj6gnd/Screenshot%202015-01-19%2015.35.03.png?dl=0

On Mon, Jan 19, 2015 at 3:27 PM, Oleksiy Radyvanyuk < notifications@github.com> wrote:

Try change your cell selector to this:

selector = "view:'IPMoreCell' marked:'Account settings' FEX_isVisible"

— Reply to this email directly or view it on GitHub https://github.com/moredip/Frank/issues/270#issuecomment-70499955.

oradyvan commented 9 years ago

So if you while on that same screen in Symbiote, will press "Touch" button for this selector - will the action happen?

madewulf commented 9 years ago

Yes, that works.

On Mon, Jan 19, 2015 at 3:39 PM, Oleksiy Radyvanyuk < notifications@github.com> wrote:

So if you while on that same screen in Symbiote, will press "Touch" button for this selector - will the action happen?

— Reply to this email directly or view it on GitHub https://github.com/moredip/Frank/issues/270#issuecomment-70502383.

oradyvan commented 9 years ago

Hm, it seems to me this is pure timing issue related to animation. Maybe, in order to not waste your time on this, just add some delay with "sleep 0.5" for example, right before touching the cell. Otherwise I have no fresh ideas on why tapping the cell from code does not happen for you.

madewulf commented 9 years ago

You were right, it's related to the animation. Actually, I just noticed that adding wait_for_nothing_to_be_animating made this precise test freeze (it never ends). Replacing by a sleep instruction made the test succeed.

Thanks a lot for your time!

On Mon, Jan 19, 2015 at 3:44 PM, Oleksiy Radyvanyuk < notifications@github.com> wrote:

Hm, it seems to me this is pure timing issue related to animation. Maybe, in order to not waste your time on this, just add some delay with "sleep 0.5" for example, right before touching the cell. Otherwise I have no fresh ideas on why tapping the cell from code does not happen for you.

— Reply to this email directly or view it on GitHub https://github.com/moredip/Frank/issues/270#issuecomment-70503410.

oradyvan commented 9 years ago

Oh, if adding call to wait_for_nothing_to_be_animating freezes your app that means most likely you are using animated UIImageViews and Frank at the moment does not process that nicely. I had to modify sources of Frank and use my own gem in order to solve this problem, however this is in closed repository and I cannot share the code with you.

madewulf commented 9 years ago

I don't think we use such thing, but maybe one of the libraries we use do. I'll try to check, but thanks for the hint!

On Mon, Jan 19, 2015 at 3:51 PM, Oleksiy Radyvanyuk < notifications@github.com> wrote:

Oh, if adding call to wait_for_nothing_to_be_animating freezes your app that means most likely you are using animated UIImageViews and Frank at the moment does not process that nicely. I had to modify sources of Frank and use my own gem in order to solve this problem, however this is in closed repository and I cannot share the code with you.

— Reply to this email directly or view it on GitHub https://github.com/moredip/Frank/issues/270#issuecomment-70504715.

seanoshea commented 9 years ago

wait_for_nothing_to_be_animating can be troublesome when dealing with UIRefreshControls as they are always 'animating' even when they are off screen.

oradyvan commented 9 years ago

Yes, and not only refresh control, but also with any UIImageView having isAnimating method return true and also animationRepeatCount return 0 that is endless animation. And in case you extend scope of windows being requested by Shelley engine to all windows, there will be problems with network activity indicator on status bar. To avoid all these issues Frank libraries need to be customized.

ondrejhanslik commented 9 years ago

Don't wait random times, don't wait for everything. Make specific wait selectors. You don't have to wait for everything to stop animating. Create a selector for the view that you expect to be animating and wait for it. If you want to touch a button, don't wait for animations, wait for the button to become touchable (there is a selector for that, something like FEX_isTouchable). Frank is very good but unfortunately new development has stopped. I tried to push some big changes when I was needing them but in the end if was easier (and faster) to just fork and work locally.

madewulf commented 9 years ago

Ok, thanks a lot for all this information, it is very precious to me!

On Tue, Jan 20, 2015 at 12:09 PM, Ondrej Hanslik notifications@github.com wrote:

Don't wait random times, don't wait for everything. Make specific wait selectors. You don't have to wait for everything to stop animating. Create a selector for the view that you expect to be animating and wait for it. If you want to touch a button, don't wait for animations, wait for the button to become touchable (there is a selector for that, something like FEX_isTouchable). Frank is very good but unfortunately new development has stopped. I tried to push some big changes when I was needing them but in the end if was easier (and faster) to just fork and work locally.

— Reply to this email directly or view it on GitHub https://github.com/moredip/Frank/issues/270#issuecomment-70638219.

kundanyevale commented 7 years ago

Thank a lot @oradyvan For how much time wait to find element(selector)? Is there any max limit to search it?

oradyvan commented 7 years ago

My apologies, I have stopped working with Frank quite a long time ago, so I have no answer to your question.