I am trying to locate the following element using selenium webdriver:
<div class="lv-product__details"><div class="lv-product__details-head"><span class="lv-product__details-sku"> M40712 </span> <div class="lv-product-add-to-wishlist"><button aria-label="Add to Wishlist" aria-disabled="false" tabindex="0" class="lv-icon-button lv-product-add-to-wishlist__button"><svg focusable="false" aria-hidden="true" class="lv-icon"><use xlink:href="/_nuxt/icons.svg#sprite-navigation-wishlist-off"></use></svg></button></div></div> <h1 class="lv-product__title"> Pochette Accessoires </h1> <div class="lv-product-variations"><button class="lv-product-variation-selector list-label-l lv-product-variations__selector" aria-expanded="false"><span class="lv-product-variation-selector__title -text-is-medium"> Material
I have tried:
from selenium import webdriver from selenium.webdriver.chrome.options import Options url = "https://en.louisvuitton.com/eng-nl/products/pochette-accessoires-monogram-005656" options = Options() options.headless = True driver = webdriver.Chrome('path/to/chromedriver', chrome_options=options) driver.get(url) elem = driver.find_element_by_class_name("lv-product__details")
or via Xpath
elem = driver.find_element_by_xpath('//*[@id="__layout"]/div/div[2]/div[2]/div[1]/div[1]/div[2]')
but the elem is returned as an empty list. is there something that I am doing wrong / can do differently to access the contents of the website?
https://stackoverflow.com/questions/66882302/empty-element-when-using-selenium-webdriver March 31, 2021 at 01:45PM
没有评论:
发表评论