Skip to content

Commit

Permalink
fix(helper): fix helpers to scroll to elements before attempting to c…
Browse files Browse the repository at this point in the history
…lick on it (#6)
  • Loading branch information
Yannick Croissant authored Sep 6, 2019
1 parent 270a224 commit 1c52848
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/e2e/helpers/changeToggleRefinementStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ declare namespace WebdriverIOAsync {

browser.addCommand('changeToggleRefinementStatus', async () => {
const checkbox = await browser.$('.ais-ToggleRefinement-checkbox');
// Assures us that the element is in the viewport
await checkbox.scrollIntoView();

return checkbox.click();
});
2 changes: 2 additions & 0 deletions tests/e2e/helpers/clearRefinements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ declare namespace WebdriverIOAsync {

browser.addCommand('clearRefinements', async () => {
const clearButton = await browser.$(`.ais-ClearRefinements-button`);
// Assures us that the element is in the viewport
await clearButton.scrollIntoView();

await clearButton.click();

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/helpers/setNextPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ browser.addCommand('setNextPage', async () => {
const page = await browser.$(
`.ais-Pagination-item--nextPage .ais-Pagination-link`
);
// Assures us that the element is in the viewport
await page.scrollIntoView();

await page.click();

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/helpers/setPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ declare namespace WebdriverIOAsync {

browser.addCommand('setPage', async (number: number) => {
const page = await browser.$(`.ais-Pagination-link=${number}`);
// Assures us that the element is in the viewport
await page.scrollIntoView();

await page.click();

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/helpers/setPreviousPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ browser.addCommand('setPreviousPage', async () => {
const page = await browser.$(
`.ais-Pagination-item--previousPage .ais-Pagination-link`
);
// Assures us that the element is in the viewport
await page.scrollIntoView();

await page.click();

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/helpers/setRatingMenuValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ declare namespace WebdriverIOAsync {

browser.addCommand('setRatingMenuValue', async (label: string) => {
const rating = await browser.$(`.ais-RatingMenu-link[aria-label="${label}"]`);
// Assures us that the element is in the viewport
await rating.scrollIntoView();

await rating.click();

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/helpers/setSearchBoxValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ declare namespace WebdriverIOAsync {
browser.addCommand('setSearchBoxValue', async (value: string) => {
const oldUrl = await browser.getUrl();
const searchBox = await browser.$('.ais-SearchBox [type=search]');
// Assures us that the element is in the viewport
await searchBox.scrollIntoView();
// In Internet Explorer the input must be focused before updating its value
await searchBox.click();
await searchBox.setValue(value);
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/helpers/setSelectedHierarchicalMenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ declare namespace WebdriverIOAsync {
browser.addCommand('setSelectedHierarchicalMenuItem', async (label: string) => {
const oldUrl = await browser.getUrl();
const item = await browser.$(`.ais-HierarchicalMenu-label=${label}`);
// Assures us that the element is in the viewport
await item.scrollIntoView();

await item.click();

// Changing the URL will also change the page element IDs in Internet Explorer
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/helpers/setSelectedRefinementListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ declare namespace WebdriverIOAsync {
browser.addCommand('setSelectedRefinementListItem', async (label: string) => {
const oldUrl = await browser.getUrl();
const item = await browser.$(`.ais-RefinementList-labelText=${label}`);
// Assures us that the element is in the viewport
await item.scrollIntoView();

await item.click();

// Changing the URL will also change the page element IDs in Internet Explorer
Expand Down

0 comments on commit 1c52848

Please sign in to comment.