Answers for "how to extract a value in attributes in seleniym python"

0

how to extract a value in attributes in seleniym python

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
"""
<div class="gallery-list">
<figure class="figure hd" ng-class="profileGallery.css" profile-item-remove="9>
    <a href="https://#" data-login="" gallery-modal="9" rel="nofollow">
    <picture sl-video-preview="https://movie.mp4" sl-safe="" class="ng-isolate-scope sl-safe">
    </a>
</figure>
<div>
"""
# using CSS_Selector
print(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"))
# using XPATH
print(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"))
Posted by: Guest on August-22-2021

Code answers related to "how to extract a value in attributes in seleniym python"

Python Answers by Framework

Browse Popular Code Answers by Language