Python Selenium 在 Facebook 2022 上找不到添加照片和视频按钮元素

Python Selenium cant find the Add photo and video button element on Facebook 2022

我正在尝试将图片上传到 Facebook,但无法单击“添加照片和视频”按钮。

当我查看 html 时,这是我试图点击的元素:

<div aria-label="Foto/video" class="oajrlxb2 gs1a9yip mtkw9kbi tlpljxtp   qensuy8j 
ppp5ayq2 nhd2j8a9 mg4g778l pfnyh3mw p7hjln8o tgvbjcpo hpfvmrgz 
esuyzwwr f1sip0of n00je7tq arfg74bv qs9ysxi8 k77z8yql pq6dq46d b
twxx1t3 abiwlrkh p8dawk7l lzcic4wl dwo3fsh8 g5ia77u1 goun2846 c
cm00jje s44p3ltw mk2mc5f4 rt8b4zig n8ej3o3l agehan2d sk4xxmp2 r
q0escxv kvgmc6g5 cxmmr5t8 oygrvhab hcukyx3x jb3vyjys rz4wbd8a q
t6c0cv9 a8nywdso l9j0dhe7 i1ao9s8h du4w35lb" role="button" tabindex="0"><div><div><div class="tv7at329 l9j0dhe7 thwo4zme 
s45kfl79 emlxlaya bkmhp75w spb7xbtv"><div class="iyyx5f41 l
9j0dhe7 cebpdrjk bipmatt0 k5wvi7nf a8s20v7p k77z8yql qs9ysxi8 
arfg74bv n00je7tq a6sixzi8 tojvnm2t"><div class="bp9cbjyn j83agx80 taijpn5t l9j0dhe7 datstx6m k4urcfbm"><i data-visualcompletion="css-img" class="hu5pjgll bixrwtb6" style="height: 24px; width: 24px; background-image: u
rl(&quot;https://static.xx.fbcdn.net/rsrc.php/v3/yr/r/KzmUzY1_3Zb.png&quot;); background-position: 0px -282px; background-size: auto; background-repeat: no-repeat; display: inline-block;"></i></div><div class="n00je7tq arfg74bv qs9ysxi8 k77z8yql i09qtzwb n7fi1qx3 b5wmifdl hzruof5a pmk7jnqg j9ispegn kr520xx4 c5ndavph art1omkt ot9fgl3s rnr61an3" data-visualcompletion="ignore"></div></div></div></div><div><div></div></div></div></div>

我想用webdriverwait点击它但是我没有成功

我没有看到 Foto/video 属性(可能是由于地理位置 location/domain),但这里有一个类似的属性: 我可能在大多数情况下都使用 time.sleep,但是对于有问题的点击,即 Photo/video 按钮,我根据需要使用了 webdriverwait。

WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//*[text()='Photo/video']"))).click()

如果您想使用 aria-label(在您的查询中),您可以尝试使用 xpath 作为 //*[@aria-label='Foto/video']