can someone be able to understand what the problem of this code is?I understand that the question is not new, but what I found just didn't help me, but maybe I was looking badly
wd = webdriver.Chrome('chromedriver',options=chrome_options)
wd.get('https://www.uniprot.org/uniprotkb/Q14050/entry')
sleep(15)
Molmass = wd.find_element('xpath','//*[@id="sequences"]/div/div[2]/section/ul/li[2]/div/div[2]')
HTML:
<div class="decorated-list-item__content">63,616</div>
Selector:
#sequences > div > div.card__content > section > ul > li:nth-child(2) > div > div.decorated-list-item__content
XPATH:
//*[@id="sequences"]/div/div[2]/section/ul/li[2]/div/div[2]
Error:
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="sequences"]/div/div[2]/section/ul/li[2]/div/div[2]"}
(Session info: headless chrome=107.0.5304.87)
I tried searching by class, selectors, xpath, but nothing helps, I tried to set a timer so that the page had time to load, but there was no result
I am assuming you are trying the get the value ' 63,616
', for that you can use any one of the below locators:
CSS_SELECTOR:
driver.find_element(By.CSS_SELECTOR, ".sequence-container li:nth-of-type(2) .decorated-list-item__content").text
XPATH:
driver.find_element(By.XPATH, ".//section[@class='sequence-container']//li[2]//div[@class='decorated-list-item__content']").text
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.