Teun
Teun

Reputation: 221

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

I am trying to upload an image to Facebook, but I am unable to click on the Add photo and video button.

When I am looking at the html, this is the element I am trying to click:

<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>

I want to click it with webdriverwait but I don't succeed.

Upvotes: 0

Views: 129

Answers (1)

Anand Gautam
Anand Gautam

Reputation: 2101

I do not see a Foto/video attribute as exactly (maybe due to geo location/domain), but a similar one is here: I probably used time.sleep in most of the occasions, but for the click in question, which is the Photo/video button, I used webdriverwait, just as needed.

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

If you want to use aria-label (as in your query), you may try using the xpath as //*[@aria-label='Foto/video']

Upvotes: 1

Related Questions