hound icon indicating copy to clipboard operation
hound copied to clipboard

sleep/wait on page without losing focus

Open mbenatti opened this issue 7 years ago • 2 comments

Hello folks, I have a code that navigate to the url and need to wait 5/10 seconds with keeping focus on to execute/validade some Javascript after...

The way I have found to sleep in a page without close the process is to use the :timer.sleep\1 but when I use :timer.sleep\1 the pages lose the Focus and invalidate by test case

note: The page has a counter, that count decreasing the time when I have focus on, when I lose focus on Page, I got a message like "Please keep this ad on focus..." like the image above.

The screenshot image when I navigate_to him:

navigate image

The screenshot image after sleep for 15 seconds: ( :timer.sleep(15000))

after sleep image

Note when I tried to stay on Page in stand by using :timer.sleep\1 I just lose the focus

Thanks in advance and for awesome library

mbenatti avatar Jul 12 '17 05:07 mbenatti

It seems unlikely that :timer.sleep\1 is causing your problem. Hound commands send API calls to your webdriver of choice to interact with the page, and :timer.sleep\1 wouldn't do that.

Is there something specific that you're waiting to happen? You might try repeatedly testing for that specific condition until it is true before proceeding. You can send any Javascript you want with ScriptExecution.execute_script\1, and the return value of the script should be the return value of that function in Elixir.

darksheik avatar Jul 12 '17 13:07 darksheik

@darksheik May because I'm calling :timer.sleep\1 inside the process and not using a helper function inside the Hound, I think so, that calling it will lose the focus

For the second question I need to wait the server keeping the focus on browser, its not about calling some Javascript. may I can try something with Javascript (but its hard to find in obfuscated javascript and calling setTimeout() doest work as well) but the ideal is to do that with Hound function without lose focus

mbenatti avatar Jul 12 '17 21:07 mbenatti