0

I am working with python and selenium to click on the Photo/Video button on a facebook page. The HTML associated with this seems to have a list item (li) inside a ui. The html is as in the following image. The button circles is the one I am trying to press.

Can anyone please tell me how should I press the Photo/Video button?

enter image description here

Umar Dastgir
  • 688
  • 9
  • 25

2 Answers2

0

Can you try this code?

I used the xPath method and contains() to compare the text in the div.

By the way, the found object does not have the click related function, and the click function seems to be a tag among its parents

The syntax for finding a parent in xPath is /.. and I used this

https://stackoverflow.com/a/3655588/12582501

driver.find_element_by_xpath('//div[contains(text(),"Photo/Video")]/../../../a').click()
joonghyup cha
  • 624
  • 3
  • 12
0

Facebook has an intresting thing: testids With this IDs you can click all of clickable elements on the site

driver.find_element_by_xpath('//div[@data-testid="photo-video-button"]').click()

In this case you can exec your code, when on page will be another element with text "Photo/Video"

  • I tried this, but get the following message "Message: element click intercepted: Element is not clickable at point (329, 634)" – Umar Dastgir Dec 30 '19 at 07:09