-3

I am using calabash automation with Ruby for my project in iOS.

scenario/Ruby:

Given(/^I click Login$/) do

  homePage = page(HomePage)

  homePage.loginButton()

  sleep(3)

end

 When(/^I enter valid credentials$/) do

   loginPage = page(LoginPage)

   loginPage.enterEmailaddress()

   loginPage.enterPassword()

   loginPage.done()

   sleep(3)

   loginPage.loginButton()

   sleep(5)

 end

As you can see I am using sleep() many times Is there any other command that can be used instead of sleep()

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Rani
  • 1
  • 3
  • 2
    What exactly are you waiting for, each time you `sleep`? Is there some way you can explicitly wait for these events, rather than waiting 3-5 seconds and hoping for the best? – Tom Lord Sep 27 '16 at 15:47
  • It isn't clear what you want to do differently. Are you waiting for something to happen then continue? Do you just want to delay a certain amount of time? You need to explain the situation better. Please read "[ask]" including the linked pages. – the Tin Man Sep 27 '16 at 19:22
  • @TomLord :Sorry wasnt clear,I am waiting for the page to load.There is a spinner spinning when the loginButton() is clicked and waiting for the login page to appear. – Rani Sep 29 '16 at 13:02
  • @theTinMan:After the done button is clicked,the keyboard is dismissed,so I kept a sleep() for that action. – Rani Sep 29 '16 at 13:04
  • As was suggested below, perhaps `await` is all you need. Or, depending on the exact behaviour, perhaps you could explicitly wait for a specific AJAX request to be completed. – Tom Lord Sep 29 '16 at 13:20
  • probably I would explain a bit more in detail.I have one page booking widget.my code comes to this page.then the code should wait for the page to load.Then the code should scroll down to enter email address in the text box.Thats my requirement.The script fails as the code is not waiting for page to load and also cannot scroll to the bottom.So I need proper commands to use for this requirement.Many thanks everyone – Rani Oct 13 '16 at 10:25

1 Answers1

0

You might be looking for the await method:

The await method just returns the page object after waiting for the page to be loaded

As always, read the docs.

https://github.com/calabash/x-platform-example#step-2---step-definitions

DiegoSalazar
  • 13,361
  • 2
  • 38
  • 55