I am scraping a page heavy with JS, where I select a js button
driver.find_element_by_css_selector('.u-textColorDarker').click()
which displays a from. Inside that form, some info is displayed, but to get all the content there is a button ("show more") that needs to be clicked n times to display all the content. When there is nothing else to show, the button disappears.
In this particular page, the button needs to be clicked 3 times. So a quick solution for my problem in:
driver.find_element_by_css_selector('.js-showMoreRecommends').click()
time.sleep(2)
driver.find_element_by_css_selector('.js-showMoreRecommends').click()
time.sleep(2)
driver.find_element_by_css_selector('.js-showMoreRecommends').click()
time.sleep(2)
Is there a way to put this in a loop, so the action is done inside a loop until the selector '.js-showMoreRecommends' is no longer present?
while True:and break out of it when your condition is met