Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Add dynamic wait to allow page content to render #331

Merged
merged 2 commits into from
Feb 23, 2021

Conversation

itbm
Copy link
Contributor

@itbm itbm commented Feb 22, 2021

Issue #, if available:
Fixes #330

Description of changes:
Add wait before screenshot to allow content to render

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

@codecov
Copy link

codecov bot commented Feb 22, 2021

Codecov Report

Merging #331 (58063f4) into dev (fb3cdf8) will increase coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev     #331      +/-   ##
============================================
+ Coverage     64.04%   64.14%   +0.10%     
  Complexity      291      291              
============================================
  Files           100      100              
  Lines          4066     4078      +12     
  Branches        619      622       +3     
============================================
+ Hits           2604     2616      +12     
  Misses         1302     1302              
  Partials        160      160              
Flag Coverage Δ Complexity Δ
Kibana-reports 77.37% <100.00%> (+0.14%) 0.00 <0.00> (ø)
reports-scheduler 53.28% <ø> (ø) 0.00 <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...r/routes/utils/visual_report/visualReportHelper.ts 87.14% <100.00%> (+2.66%) 0.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb3cdf8...58063f4. Read the comment docs.

Copy link
Member

@zhongnansu zhongnansu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to avoid hardcode as mush as possible. Could you think of using any puppeteer APIs that doesn't require a interval as input? Something like waitUntil(), waitForNavigation. May need to look up their API doc as well

@itbm
Copy link
Contributor Author

itbm commented Feb 22, 2021

I had looked at those originally, but could not see any able to take in to account scripts still modifying html after page load (at least not without adding a waitForSelector).

@itbm
Copy link
Contributor Author

itbm commented Feb 23, 2021

@zhongnansu I have tested the other options and they all result in the blank plugin

@zhongnansu
Copy link
Member

@itbm Hi, I found someting on the internet which could be a possible generic solution for waiting for client side JS scripts to complete.
https://stackoverflow.com/a/61304202
Also, I think page.waitFor is going to deprecate, maybe try page.waitForTimeout()?

@itbm
Copy link
Contributor Author

itbm commented Feb 23, 2021

@itbm Hi, I found someting on the internet which could be a possible generic solution for waiting for client side JS scripts to complete.
https://stackoverflow.com/a/61304202

I think this kind of idea is probably ok for most use cases and adds some flexibility to extend the wait vs a simple page.waitFor(x).

Also, I think page.waitFor is going to deprecate, maybe try page.waitForTimeout()?

page.waitForTimeout() is not available in the included puppeteer version so cannot be used until the package is upgraded.

Copy link
Contributor

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix

@zhongnansu zhongnansu changed the title Add wait to allow page content to render Add dynamic wait to allow page content to render Feb 23, 2021
@zhongnansu zhongnansu merged commit ba7c8b7 into opendistro-for-elasticsearch:dev Feb 23, 2021
zhongnansu pushed a commit to zhongnansu/kibana-reports that referenced this pull request Jul 1, 2021
zhongnansu pushed a commit to zhongnansu/kibana-reports that referenced this pull request Jul 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Report empty if using plugins with client side calculations
3 participants