Gives data only through debugging selenium

Question:

I have a problem, I have a code

browser1.get("https://www.artstation.com/artwork/LeAN1P")


element = browser1.find_elements(by=By.CSS_SELECTOR, value='div.d-flex:nth-child(2) >  span:nth-child(2)')
for el in element:
    print(el.text)

I need to get the Views parameter, but everything ends with the successful execution of the code, despite the fact that if you run it through debug, then everything works

Debug console

Run console

if you integrate the code into another, then an error pops up, tell me how you can get the Views text data from this page
launch in another finished project

no ideas please help

Asked By: Gazaby UnkOmia

||

Answers:

Your elements are simply not loaded yet when script in run mode, as it’s faster than debug. Before finding element wait for it to be located/visible etc
https://selenium-python.readthedocs.io/waits.html

Answered By: kadis
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.