I want to scroll the contacts of web WhatsApp and click on the particular contact. I am able to scroll the contacts but not able to find the specific element to get particular contact because HTML is dynamic, as I scroll the contacts it gets changed. Here is the code:
target = '"name"'
panel = driver.find_element_by_class_name('_1NrpZ')
a = 0
while elem is None:
a += 5
try:
driver.execute_script('arguments[0].scrollTop = %s' %a, panel)
elem = driver.find_element_by_xpath('//span[@title=' + target + ']')
time.sleep(5)
except:
pass
ac = ActionChains(driver)
ac.move_to_element(elem).click().perform()
time.sleep(2)
It does not stop and keeps scrolling until the last contact. I think when I scroll new HTML is not loaded so is there any solution?