gpt4 book ai didi

python - selenium可以在outlook online中find_element_by_xpath吗?

转载 作者:太空宇宙 更新时间:2023-11-03 21:39:26 25 4
gpt4 key购买 nike

我在 Outlook 在线 html 中通过 xpath 或 id 查找元素时遇到问题。我正在使用 Selenium 和 python 。这是我写的。

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException #imports

browser = webdriver.Chrome('C:\\Users\\...')
browser.get('https://www.office.com/...') #setup

#then some code to sign into outlook online

browser.find_element_by_xpath('//*[@id="_ariaId_64"]/div/div/div[1]')

browser.find_element_by_xpath('//*[@id="MailFolderPane.FavoritesFolders"]/div[19]')

browser.find_element_by_id('_ariaId_68') #attempts to find an element in outlook

这是我试图访问的元素。我会发布整个 html,但内容就这么多了。我对所有代码都是全新的,所以对我要轻松一些:)

<div>
<div id="_ariaId_68" aria-expanded="false" draggable="true" dropzone="string:text/plain">
<div autoid="_n_R" class="_n_44 canShowFavoritesAction" role="treeitem" aria-expanded="false" aria-labelledby="_ariaId_68.folder _ariaId_68.ucount" aria-haspopup="true" tabindex="-1">
<div class="_n_S3 nowrap border-color-transparent _n_X3" style="padding-left: 4px;">
<div class="_n_V3 _n_54">
<span autoid="_n_S" class="_n_W3 ms-font-m ms-fwt-sl _n_Y3" id="_ariaId_68.folder" title="Sent Items">Sent Items</span>
<div class="_n_24 ms-bg-color-neutralLighter"> <span autoid="_n_T" class="ms-font-m _n_Z3 ms-fwt-sb ms-fcl-tp" aria-hidden="true"></span> </div>
<span class="ms-font-s ms-fcl-ns" aria-hidden="true" aria-expanded="false" aria-haspopup="true" tabindex="-1"> </span> <button autoid="_n_U" type="button" class="_n_34 ms-fwt-r ms-fcl-ns o365button hidden" style="display: none;" tabindex="-1"></button> <span style="display: none;" aria-hidden="true"></span>
</div>
<div class="_n_14 hidden"><button autoid="_n_V" type="button" class="_n_04 firefoxFavorite o365button" title="Remove from Favorites" aria-labelledby="_ariaId_69"><span class="_fc_3 owaimg ms-Icon--star ms-icon-font-size-18 ms-fcl-ns-b"> </span><span class="_fc_4 o365buttonLabel _fc_2" id="_ariaId_69" style="display: none;"></span></button></div>
</div>
</div>
</div>
</div>

最佳答案

假设您正在尝试查找已发送项目的 - 网络元素。

SENT ITEM 链接似乎不是可见区域[当收件箱内有更多子文件夹时,通常会发生这种情况],因此您首先滚动以查看该元素,然后再对元素执行任何操作。

Here are the options to bring the element to visible area

尝试使用以下 xpath//span[@title='已发送邮件']

关于python - selenium可以在outlook online中find_element_by_xpath吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52995466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com