-
Notifications
You must be signed in to change notification settings - Fork 609
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
Add scrollTo selector #774
Open
aliu145
wants to merge
12
commits into
garris:master
Choose a base branch
from
aliu145:anna.liu/add-scrollTo-selector
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b9f926f
Update clickAndHoverHelper.js
aliu145 b9fdcd3
Update clickAndHoverHelper.js
aliu145 0712adf
Merge pull request #2 from aliu145/anna.liu/add-scrollTo-selector-1
aliu145 7d0b902
Update README.md
aliu145 a394746
Merge pull request #3 from aliu145/anna.liu/add-scrollTo-selector-2
aliu145 bd77957
Adding test for scrollToSelector
019e1d9
Update index.html
aliu145 2a019aa
Update backstop_features.js
aliu145 24a52dd
Merge pull request #4 from aliu145/master
aliu145 7d9c350
Merge branch 'anna.liu/add-scrollTo-selector' of https://github.com/a…
e4c2770
Adding tests for scrollToSelector
c0640ee
update test label
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module.exports = function (chromy, scenario) { | ||
var hoverSelector = scenario.hoverSelector; | ||
var clickSelector = scenario.clickSelector; | ||
var scrollToSelector = scenario.scrollToSelector; | ||
var postInteractionWait = scenario.postInteractionWait; // selector [str] | ms [int] | ||
|
||
if (hoverSelector) { | ||
|
@@ -18,6 +19,14 @@ module.exports = function (chromy, scenario) { | |
.click(clickSelector); | ||
} | ||
|
||
if (scrollToSelector) { | ||
chromy | ||
.wait(scrollToSelector) | ||
.evaluate(function() { | ||
document.querySelector(scrollToSelector).scrollIntoView(); | ||
}, scrollToSelector); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @garris, I made these updates but it's still not working (ie the screenshot shows that it did not properly scroll the container) |
||
} | ||
|
||
if (postInteractionWait) { | ||
chromy.wait(postInteractionWait); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+17.4 KB
.../bitmaps_reference/puppeteer_backstop_features_scrollTo_0_lemurFace_0_phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.4 KB
...bitmaps_reference/puppeteer_backstop_features_scrollTo_0_lemurFace_1_tablet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<style> | ||
.scrollable-container { | ||
background-color: lightblue; | ||
width: 500px; | ||
height: 175px; | ||
overflow: scroll; | ||
} | ||
|
||
.image-box { | ||
width: 200px; | ||
margin: auto; | ||
} | ||
|
||
img.lemurFace { | ||
display: block; | ||
width: 100%; | ||
height: auto; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="main-page-layout"> | ||
<div class="scrollable-container"> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna tellus, pellentesque | ||
eget sagittis quis, ullamcorper sed sapien. Proin eget mollis nulla. Sed dapibus arcu id | ||
pretium ornare. Sed at faucibus tellus. Vestibulum sed efficitur dui, ut dapibus diam. | ||
Suspendisse potenti. Curabitur porta, justo quis convallis dictum, nulla ex rutrum ante, eu | ||
arius velit dui in libero. Vestibulum eleifend vitae ipsum in mattis. Vivamus sed tempor quam. | ||
Quisque vulputate feugiat lobortis. Aliquam erat volutpat. | ||
</p> | ||
|
||
<div class="image-box"> | ||
<img id="lemurFace" src="../../../assets/lemurFace.png" class="lemurFace"> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const ENGINE = 'chromy'; | ||
const SCRIPT_PATH = 'chromy'; | ||
|
||
module.exports = { | ||
id: `${ENGINE}_backstop_features`, | ||
viewports: [ | ||
{ | ||
label: 'phone', | ||
width: 320, | ||
height: 480 | ||
}, | ||
{ | ||
label: 'tablet', | ||
width: 1024, | ||
height: 768 | ||
} | ||
], | ||
onBeforeScript: `${SCRIPT_PATH}/onBefore.js`, | ||
onReadyScript: `${SCRIPT_PATH}/onReady.js`, | ||
scenarios: [ | ||
{ | ||
label: 'scrollTo', | ||
url: './index.html', | ||
scrollToSelector: '.lemurFace', | ||
selectors: ['.lemurFace'] | ||
} | ||
], | ||
paths: { | ||
bitmaps_reference: '../backstop_data/bitmaps_reference', | ||
bitmaps_test: '../backstop_data/bitmaps_test', | ||
engine_scripts: '../backstop_data/engine_scripts', | ||
html_report: '../backstop_data/html_report', | ||
ci_report: '../backstop_data/ci_report' | ||
}, | ||
report: ['browser'], | ||
engine: ENGINE, | ||
engineOptions: {}, | ||
asyncCaptureLimit: 10, | ||
asyncCompareLimit: 50, | ||
debug: false, | ||
debugWindow: false, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const ENGINE = 'puppeteer'; | ||
const SCRIPT_PATH = 'puppeteer'; | ||
|
||
module.exports = { | ||
id: `${ENGINE}_backstop_features`, | ||
viewports: [ | ||
{ | ||
label: 'phone', | ||
width: 320, | ||
height: 480 | ||
}, | ||
{ | ||
label: 'tablet', | ||
width: 1024, | ||
height: 768 | ||
} | ||
], | ||
onBeforeScript: `${SCRIPT_PATH}/onBefore.js`, | ||
onReadyScript: `${SCRIPT_PATH}/onReady.js`, | ||
scenarios: [ | ||
{ | ||
label: 'scrollTo', | ||
url: './index.html', | ||
scrollToSelector: '.lemurFace', | ||
selectors: ['.lemurFace'] | ||
} | ||
], | ||
paths: { | ||
bitmaps_reference: '../backstop_data/bitmaps_reference', | ||
bitmaps_test: '../backstop_data/bitmaps_test', | ||
engine_scripts: '../backstop_data/engine_scripts', | ||
html_report: '../backstop_data/html_report', | ||
ci_report: '../backstop_data/ci_report' | ||
}, | ||
report: ['browser'], | ||
engine: ENGINE, | ||
engineOptions: {}, | ||
asyncCaptureLimit: 10, | ||
asyncCompareLimit: 50, | ||
debug: false, | ||
debugWindow: false, | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably also need to guard against scrollToSelector not being found.