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

webdriver.executeScript wait a long time(26s) before page load #2

Closed
huan opened this issue May 10, 2016 · 3 comments
Closed

webdriver.executeScript wait a long time(26s) before page load #2

huan opened this issue May 10, 2016 · 3 comments

Comments

@huan
Copy link
Member

huan commented May 10, 2016

It seems that webdriver always wait browser window to be stable before run executeScript.

the condition of stable is set to be like this:

window.document.readyState === 'complete'

But...

If we have a ajax call / http long pulling / etc, the readyState will be interactive for a long time.

Solution(?)

make webdrive wait only for readyState is loading

See Also

  1. How to executeScript before page load by WebDriver in selenium? https://stackoverflow.com/questions/37071807/how-to-executescript-before-page-load-by-webdriver-in-selenium
  2. A ghost driver on phantomjs quick & dirty patch https://github.com/detro/ghostdriver/issues/334#issuecomment-41361564
  3. Attempt to make selenium tests more reliable https://github.com/18F/calc/pull/267
  4. PhantomJS 1.9 has introduced resourceTimeout

PhantomJS Log

When waiting, it output lots of logs like this:

[DEBUG - 2016-08-07T10:21:57.754Z] Session [b69451a0-5c88-11e6-bed4-fb6eca6b39c0] - _execFuncAndWaitForLoadDecorator - Page Loading in Session: true

PhantomJS Code

Do not know what SIGNAL is, what SLOT is...

https://github.com/ariya/phantomjs/blob/096d0da87ee6d94f3eed84446c0eb5176566d54a/src/webpage.cpp#L396

GhostDriver Code

https://github.com/detro/ghostdriver/blob/f976007a431e634a3ca981eea743a2686ebed38e/src/session.js#L233

maybe change _isLoading() to this?

    /**
     * Is any window in this Session Loading?
     * @returns "true" if at least 1 window is loading.
     */
    _isLoading = function() {
        var wHandle;

        for (wHandle in _windows) {
//            if (_windows[wHandle].loading) {
            if (_windows[wHandle].document.readyState) === 'loading')
                return true;
            }
        }

        // If we arrived here, means that no window is loading
        return false;
    }
huan pushed a commit that referenced this issue Nov 7, 2016
@huan huan changed the title webdriver.executeScript wait a long time before page load webdriver.executeScript wait a long time(26s) before page load Nov 13, 2016
@bastrich
Copy link

bastrich commented Feb 7, 2017

@zixia Use the following option
capabilities.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, "none);

@huan
Copy link
Member Author

huan commented Feb 7, 2017

@bastrich Thanks for the information!

However, I can not found setCapability method in selenium-webdriver nodejs module.

There's nothing outputed by the following commands:

01:38:19 (master) ~/git/wechaty/node_modules/selenium-webdriver$ grep setCapability * -R
01:38:55 (master) ~/git/wechaty/node_modules/selenium-webdriver$ grep CapabilityType * -R

After a search on selenium repository at here: https://github.com/SeleniumHQ/selenium/search?utf8=%E2%9C%93&q=PAGE_LOAD_STRATEGY , I also did not found any more information about it.

Could you confirm it works with nodejs and chrome? If so, can you post a runnable nodejs code for it?

Thanks!

huan added a commit that referenced this issue Oct 8, 2017
@huan
Copy link
Member Author

huan commented Oct 8, 2017

This issue should be fixed at v0.10 or above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants