Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sleep/wait on page without losing focus #169

Open
mbenatti opened this issue Jul 12, 2017 · 2 comments
Open

sleep/wait on page without losing focus #169

mbenatti opened this issue Jul 12, 2017 · 2 comments

Comments

@mbenatti
Copy link

mbenatti commented Jul 12, 2017

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

@darksheik
Copy link
Contributor

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.

@mbenatti
Copy link
Author

mbenatti commented Jul 12, 2017

@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 mbenatti changed the title sleep on page without losing focus sleep/wait on page without losing focus Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants