1from selenium.webdriver.support.ui import WebDriverWait
2from selenium.webdriver.common.by import By
3from selenium.webdriver.support import expected_conditions as EC
4"""
5<div class="gallery-list">
6<figure class="figure hd" ng-class="profileGallery.css" profile-item-remove="9>
7 <a href="https://#" data-login="" gallery-modal="9" rel="nofollow">
8 <picture sl-video-preview="https://movie.mp4" sl-safe="" class="ng-isolate-scope sl-safe">
9 </a>
10</figure>
11<div>
12"""
13# using CSS_Selector
14print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.gallery-list > figure.figure.hd > a > picture.ng-isolate-scope.sl-safe"))).get_attribute("sl-video-preview"))
15# using XPATH
16print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//div[@class='gallery-list']/figure[@class='figure hd']/a/picture[@class='ng-isolate-scope sl-safe']"))).get_attribute("sl-video-preview"))