new to python and selenium. For fun, I'm scraping a page. I have to click a first button for Comment, and then another button for All comments so I can get them all. The first click works, but not the second. I've set a hardcoded scroll, but still not working.
This is the python code I'm working on:
boton = driver.find_element_by_id('tabComments_btn')
boton.click()
wait = WebDriverWait(driver, 100)
from here on, it doesnt work (it scrolls but it says 'elem cant be scrolled into view'
driver.execute_script("window.scrollTo(0, 1300)")
botonTodos= driver.find_element_by_class_name('thread-node-children-load-all-btn')
wait = WebDriverWait(driver, 100)
botonTodos.click()
If I only click the first button, I'm able to scrape the first 10 comments, so this is working.
wait.until(EC.presence_of_element_located((By.CLASS_NAME, 'thread-node-message')))
for elm in driver.find_elements_by_css_selector(".thread-node-message"):
print(elm.text)
This is the part of the HTML I'm stuck in:
<a href="#" class="thread-node-btn thread-node-children-load-next-btn">Load next 10 comments</a>
<a href="#" class="thread-node-btn thread-node-children-load-all-btn">Load all comments</a>
<a href="#" class="thread-node-btn thread-node-btn-post">Publicar un comentario</a>
There's a whitespace node with the tag #text between each . Any ideas welcome. Thanks.