gpt4 book ai didi

Python Selenium 无法使用绝对 xpath div 查找元素

转载 作者:太空宇宙 更新时间:2023-11-03 20:17:03 24 4
gpt4 key购买 nike

我读了一天多的网页和 stackoverflow 帖子,我已经到了这样的地步:我“大部分”获得了一个动态 xPath 来点击,但它没有点击...

目标是动态地将用户从交易 View 专用指标的邀请列表中删除。单击管理访问会创建一个弹出窗口,在其中输入或删除用户。我可以很好地添加用户,但是尝试单击列表中用户名旁边的“x”确实很困难,因为除了自定义数据用户名标签和范围文本值之外,嵌套的 div 是相同的。

简而言之,我可以获得绝对 xpath,我尝试单击它,但我得到一个无法找到的元素,我知道这不是真的。

删除用户参数

取消订阅 - 传递以从电视中删除的用户列表
htmlsource - self.driver.page_source 传递以获取每个用户删除按钮的 xpath。

设置Python 3.7.3+ Selenium 美丽汤

错误消息

Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 493, in <module>
start = TV(headless=False, browser='firefox',logintype='auto')
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 91, in __init__
self.update_tv(headless=headless, username=self.username, password=self.password, browser=self.browser)
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 120, in update_tv
self.manage_users(google_sheet_user_list)
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 354, in manage_users
self.removeusers(removeoldusers, htmlsource)
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 422, in removeusers
self.driver.find_element(By.XPATH,UNSUBSCRIBEUSER_BTN).click()
File "C:\Users\user\PycharmProjects\MG_TV_Users\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Users\user\PycharmProjects\MG_TV_Users\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\user\PycharmProjects\MG_TV_Users\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: /html/body/div[11]/div/div/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/div[2]/div

删除用户的功能

def removeusers(self, unsubscribed, htmlsource):
import re
tv_users = []
names = BS(htmlsource, features="html.parser")
result = names.find_all("div", {"class": "tv-manage-access-dialog__user-list-row"})
for res in result:
#print(res)
tv_users.append(res.text)

#print(elem)


tempsave = '/html/body/div[11]/div/div/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/div[2]/div'

#PARENT DIV TO ALL USERS'tv-manage-access-dialog__user-list-body js-user-list'
tv_user_list = '/html/body/div[11]/div/div/div[2]/div/div[2]/div[2]/div[1]/div'

print('working on arviman')
#tempsave = '/html/body/div[11]/div/div/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/div[2]/div'
for user in result:
if user.text in unsubscribed:
elem = names.find(string=re.compile(user.text))
UNSUBSCRIBED_ROOT_XPATH = self.xpath_soup(elem)
tostrip = '/div[1]/span' #GOES UP 2 ELEMENTS FROM SPAN NAME TO ROOT DIV OF USER.
toappend = '/div[2]/div' # LOCATION OF BUTTON 'X' TO REMOVE USER
if UNSUBSCRIBED_ROOT_XPATH.endswith(tostrip):
UNSUBSCRIBED_ROOT_XPATH = UNSUBSCRIBED_ROOT_XPATH.replace(tostrip, '')
UNSUBSCRIBEUSER_BTN = UNSUBSCRIBED_ROOT_XPATH + toappend
self.driver.find_element(By.XPATH,UNSUBSCRIBEUSER_BTN).click()
print(user.text , "REMOVED")

管理访问弹出窗口 - 列表

<div class="tv-dialog js-dialog tv-dialog--popup i-focused ui-draggable" tabindex="-1" style="width: calc(100% - 20px); max-width: 500px; top: 459px; left: 265px; z-index: 112;">
<div class="tv-dialog__section tv-dialog__section--title js-dialog__drag tv-dialog__grab ui-draggable-handle">
<div class="js-title-text tv-dialog__title">Manage Pine Script Access</div>
</div>
<div>
<div>
<div class="tv-dialog__section tv-manage-access-dialog__section js-search-placeholder">
<div class="tv-search-row">
<input class="tv-search-row__input js-input-control" type="text" name="q" value="" autocomplete="off" data-role="search" placeholder="Add user">
<span class="tv-search-row__input-reset i-hidden js-reset-button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 95.939 95.939" width="95.939" height="95.939">
<path d="M62.82 47.97l32.53-32.534a2 2 0 0 0 0-2.828L83.332.586a2 2 0 0 0-2.827 0L47.97 33.12 15.435.587c-.75-.75-2.078-.75-2.828 0L.587 12.607a2 2 0 0 0 0 2.83L33.12 47.97.588 80.504a2 2 0 0 0 0 2.828l12.02 12.02a1.997 1.997 0 0 0 2.83 0L47.97 62.818l32.535 32.535a2 2 0 0 0 2.827 0l12.02-12.02c.78-.783.78-2.05 0-2.83L62.82 47.97z"></path>
</svg>
</span>
<span class="tv-search-row__search-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18px" height="18px">
<path fill-rule="evenodd" d="M12.5 11h-.79l-.28-.27A6.47 6.47 0 0 0 13 6.5 6.5 6.5 0 1 0 6.5 13c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L17.49 16l-4.99-5zm-6 0C4.01 11 2 8.99 2 6.5S4.01 2 6.5 2 11 4.01 11 6.5 8.99 11 6.5 11z"></path>
</svg>
</span>
<div class="tv-username-hint-list js-hidden tv-username-hint-list--full-border" style="left: 0px; top: 100%; width: 65%; z-index: 100;"></div>
</div>
</div>
<div class="tv-dialog__section tv-manage-access-dialog__section">
<div class="tv-text tv-manage-access-dialog__user-list-header js-user-list-header">14 users have access</div>
<div class="tv-manage-access-dialog__user-list-container tv-dialog__scroll-wrap js-dialog__scroll-wrap wrapper-2KWBfDVB- sb-scroll-active" style="">
<div class="tv-dialog__scroll-wrap-inner js-user-list-attach" style="bottom: auto; top: 0px;">
<div class="tv-manage-access-dialog__user-list-body js-user-list">
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="snub-fighter">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%2890,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3ES%3C/text%3E%3C/svg%3E"><span>snub-fighter</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="KingThies_">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="https://s3.tradingview.com/userpics/1662357-tYZf.png"><span>KingThies_</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="Eniesee_ldk">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28312,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EE%3C/text%3E%3C/svg%3E"><span>Eniesee_ldk</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="sugarjun">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%289,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3ES%3C/text%3E%3C/svg%3E"><span>sugarjun</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="dijkie">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28144,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3ED%3C/text%3E%3C/svg%3E"><span>dijkie</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="PaulAdelaar">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%2884,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EP%3C/text%3E%3C/svg%3E"><span>PaulAdelaar</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="ladedimone">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28102,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EL%3C/text%3E%3C/svg%3E"><span>ladedimone</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="DK32100">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28339,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3ED%3C/text%3E%3C/svg%3E"><span>DK32100</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="Pisonglobal">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28126,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EP%3C/text%3E%3C/svg%3E"><span>Pisonglobal</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="whiteltr">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%2893,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EW%3C/text%3E%3C/svg%3E"><span>whiteltr</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="nerf_herder">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="https://s3.tradingview.com/userpics/3591101-9n72.png"><span>nerf_herder</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="Swaine123">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="https://s3.tradingview.com/userpics/4117895-HxYz.png"><span>Swaine123</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="Astynaxe">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="https://s3.tradingview.com/userpics/4207689-Eli2.png"><span>Astynaxe</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="BassieWouters">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28120,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EB%3C/text%3E%3C/svg%3E"><span>BassieWouters</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
</div>
</div>
<div class="sb-inner-shadow top i-invisible"></div>
<div class="sb-inner-shadow"></div>
<div class="sb-scrollbar-wrap">
<div class="sb-scrollbar sb-scrollbar-body ui-draggable ui-draggable-handle" style="height: 317.46px; top: 1px;"></div>
</div>
</div>
</div>
</div>
</div>
<div class="tv-dialog__close js-dialog__close">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13">
<path d="M5.182 6.596L1.293 2.707.586 2 2 .586l.707.707 3.889 3.889 3.889-3.889.707-.707L12.606 2l-.707.707L8.01 6.596l3.889 3.889.707.707-1.414 1.414-.707-.707L6.596 8.01l-3.889 3.889-.707.707-1.414-1.414.707-.707 3.889-3.889z"></path>
</svg>
</div>
</div>

编辑

根据要求,我已尝试进行此更改。

        for user in result:
if user.text in unsubscribed:
self.driver.find_element_by_css_selector(f"[data-username='{user.text}'] svg").click()
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [data-username='snub-fighter'] svg

enter image description here

最佳答案

你试图在那里做什么,这很奇怪。尝试一些简单的事情,例如下面的代码:

user_list = ['ladedimone', 'PaulAdelaar', 'Swaine123']

# you're on page with unsubscribe list using Selenium

for user in user_list:
driver.find_element_by_css_selector(f"[data-username='{user}'] svg").click()

关于Python Selenium 无法使用绝对 xpath div 查找元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58384509/

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