Skip to content

Commit 2c117cb

Browse files
committed
select search element after waiting
1 parent 8d53e52 commit 2c117cb

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/api/search.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,27 @@ export class Search extends Instagram<TSearchResult> {
108108
await this.start();
109109
}
110110
try {
111-
// Attempt to click search element
112111
try {
113-
const inputElement = await this.page.waitForSelector(
114-
this.inputElementQuery,
115-
{timeout: 30000},
116-
);
117-
await inputElement.click();
118-
} catch (e) {
119-
await this.page.click(this.inputElementQuery);
112+
await this.page.waitForSelector(this.inputElementQuery, {
113+
timeout: 30000,
114+
});
115+
} catch {
116+
// Timeout
120117
}
118+
await this.page.click(this.inputElementQuery);
121119

122120
await this.page.keyboard.sendCharacter(this.searchQuery);
123121
await this.page.waitForRequest((req) => this.matchURL(req.url()));
124122
await this.processRequests();
125123
await this.page.waitForResponse((res) => this.matchURL(res.url()));
126124
await this.processResponses();
127-
await this.stop();
128-
return this.searchResult;
129125
} catch (e) {
130126
await this.stop();
131127
throw e;
132128
}
129+
130+
await this.stop();
131+
return this.searchResult;
133132
}
134133

135134
public matchURL(url: string) {

0 commit comments

Comments
 (0)