How can I remove NoSuchElementException error delay ( occurs using find_element(By.~ , "").text )

I am using selenium for review crawling.

There is some reviews have no text.

when I crawl those using find_element(By.~ , "").text, The function return NoSuchElementException error.

I can catch the error, but time delay is too long for crawling

Is there any solution to remove this delay

help me plz ^^/

The crawling code is here

        review = item.find_element(By.CSS_SELECTOR, CSS_REVIEW).text
    except NoSuchElementException:
        review = ""
    except Exception as e:
        review = ""
        print(f"Exception error : {e}")

1 answer

  • answered 2022-01-13 05:28 Max Daroshchanka

    If you have the delay before NoSuchElementException and no explicit waits defined, the reason could be that the implicitly_wait allpied which is not 0..

    So, try to set it to 0.

    //do some text search
    //then return implicitly_wait back
    driver.implicitly_wait(<some_default_value>) # seconds

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum