Home > Enterprise >  Gives data only through debugging selenium
Gives data only through debugging selenium

Time:01-09

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

CodePudding user response:

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

  • Related