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

Time:01-04

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"  role="button" tabindex="0"><div><div><div ><div ><div ><i data-visualcompletion="css-img"  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  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.

CodePudding user response:

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

  •  Tags:  
  • Related