V
V
Vyacheslav Grachunov2020-05-10 18:34:44
Python
Vyacheslav Grachunov, 2020-05-10 18:34:44

How to catch No node found for selector error in pyppeteer?

Yandex parser. Sometimes the page does not have time to load and there is no input line on it. An error occurs:
No node found for selector: input[name=text]
at this location: But the code is asynchronous and it's just text output. How to catch it as an error?
await page.focus('input[name=text]')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Yakushenko, 2020-05-10
@Qwentor

You though in traceback of an error looked, the exception which is caused is written there. You import it and process it. In your case it is:

from pyppeteer.error import PageError

try:
    ...
except PageError:
    ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question