I'm sure that this has probably been asked before, but I have yet to encounter it. My apologies if it is already up here. However, I'm having an issue trying to figure the logic out: The page begins with a list of elements (20 to begin) I'm looking to click. After a scroll, more of the same elements are displayed. I'm having an issue getting to interact with loaded elements after the scroll. This is what I've come up with so far:
def clix():
chazz = driver.find_elements_by_css_selector("button[class^='message-anywhere']")
for x in chazz:
if x.is_displayed():
x.click()
time.sleep(1)
driver.find_element_by_css_selector("button[data-control-name^='overlay.close']").click()
time.sleep(2)
scrollz()
def scrollz():
driver.execute_script("window.scrollTo(0,document.body.scrollHeight);")
time.sleep(4)
clix()
clix()
I know this isn't as 'pythonic' or 'best practices' as it should be. I'm simply worried about functionality. Any insight would be much appreciated. The
driver.find_element_by_css_selector("button[data-control-name^='overlay.close']").click() button is only to x out a pop up window.
Thanks
html:
<button class="message-anywhere-button artdeco-button artdeco-button--secondary artdeco-button--2" aria-label="Send message to Abarna Rajkumar" data-ember-action="" data-ember-action-63="63">
Chat
</button>