![](/img/trans.png)
[英]Setting a value in a text field using selenium. selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element:
[英]Selenium. NoSuchElementException
有人能理解这段代码的问题是什么吗?我知道这个问题并不新鲜,但我发现的并没有帮助我,但也许我看起来很糟糕
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>
选择器:
#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]
错误:
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)
我尝试通过 class、选择器、xpath 进行搜索,但没有任何帮助,我尝试设置一个计时器以便页面有时间加载,但没有结果
我假设您正在尝试获取值“ 63,616
”,因为您可以使用以下任一定位器:
CSS_选择器:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.