-
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
b9f926f
b9fdcd3
0712adf
7d0b902
a394746
bd77957
019e1d9
2a019aa
24a52dd
7d9c350
e4c2770
c0640ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) { | ||
|
@@ -17,6 +18,15 @@ module.exports = function (chromy, scenario) { | |
.wait(clickSelector) | ||
.click(clickSelector); | ||
} | ||
|
||
if (scrollToSelector) { | ||
chromy | ||
.wait() | ||
.evaluate(`_scrollToSelector = '${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. I dont think you need this line. |
||
.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. I think you want this...
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. You probably also need to guard against scrollToSelector not being found. 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); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module.exports = async (page, scenario) => { | ||
var hoverSelector = scenario.hoverSelectors || scenario.hoverSelector; | ||
var clickSelector = scenario.clickSelectors || scenario.clickSelector; | ||
var scrollToSelector = scenario.scrollToSelectors || scenario.scrollToSelector; | ||
var postInteractionWait = scenario.postInteractionWait; // selector [str] | ms [int] | ||
|
||
if (hoverSelector) { | ||
|
@@ -16,6 +17,15 @@ module.exports = async (page, scenario) => { | |
await page.click(clickSelectorIndex); | ||
} | ||
} | ||
|
||
if (scrollToSelector) { | ||
for (const scrollToSelectorIndex of [].concat(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. Do you intend |
||
await page.waitFor(scrollToSelectorIndex); | ||
await page.evaluate(scrollToSelectorIndex => { | ||
document.querySelector(scrollToSelectorIndex).scrollIntoView(); | ||
}, scrollToSelectorIndex); | ||
} | ||
} | ||
|
||
if (postInteractionWait) { | ||
await page.waitFor(postInteractionWait); | ||
|
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.
what does this line do?