0

I'm using Selenium with a Chromedriver. I'm trying to use Selenium to put a like on certain photos on Instagram (ie: https://www.instagram.com/p/BgWM3qEjY1H/?tagged=rugby) using the following xpath:

driver.find_element_by_xpath("//a/span[text()='Like']").click()

This worked until a few days ago. Now, Selenium throws the following exception:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a/span[text()='Like']"}
  (Session info: chrome=64.0.3282.186)
  (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.15063 x86_64)

While if I try this on Chrome, the given xpath returns the object as it should do. I've also tried to change xpath ("//*[@class='_eszkz _l9yih']") but it will still complain

Gianmarco F.
  • 780
  • 2
  • 12
  • 36
  • What `page_source` does your driver instance see after the page has finished loading? Are you sure it's actually seeing that DOM? – Ian Lesperance Mar 15 '18 at 17:52

1 Answers1

0

Solution to the problem: 1) Either use a new type of selector (ie: a css selector like .coreSpriteHeartOpen)

driver.find_element_by_css_selector(".coreSpriteHeartOpen").click()

2) Or just use an instruction for double-clicking on the photo for putting like

Gianmarco F.
  • 780
  • 2
  • 12
  • 36