Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

fix(setSearchBoxValue): reset searchbox before editing #15

Merged
merged 2 commits into from
Nov 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions helpers/setSearchBoxValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ declare namespace WebdriverIOAsync {
browser.addCommand('setSearchBoxValue', async (value: string) => {
const oldUrl = await browser.getUrl();
const searchBox = await browser.$('.ais-SearchBox [type=search]');
const resetButton = await browser.$('.ais-SearchBox [type=reset]');

// Assures us that the element is in the viewport
await searchBox.scrollIntoView();

// Click the reset button to clear the input
if (await resetButton.isDisplayed()) {
// The reset button is invisible when nothing to reset
await resetButton.click();
}

// In Internet Explorer the input must be focused before updating its value
await searchBox.click();
await searchBox.setValue(value);
Expand Down