K
K
KNT2017-10-07 11:08:10
Python
KNT, 2017-10-07 11:08:10

How to get rid of the selenium crash if the element is not found?

Hello, I recently started playing one browser game and I was impatient to write a bot to it according to this information . HABR, without thinking twice, wrote a simple crafter for myself, the essence of which is just pressing two buttons, but the problem I encountered is finding things in a backpack and when the desired thing no, the script simply crashes and refuses to work, in fact, that's the whole problem

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2017-10-07
@KNT

try-catch-exception-finally ?

A
andrejfomenko, 2017-10-08
@andrejfomenko

it is possible to write a function for checking an element, and before clicking (or simply interacting with the element), this function checks whether this element exists and whether it is available. The function is also based on try-catch-exception and a pair of if else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question