0
I’m making a bot in python using Selenium and need to click the Instagram like button using code.
To find the Like button I’m using the method find_element_by_xpath()
.
To make sure, I clicked on inspect element in Chrome and clicked on "Copy Xpath", since the xpath of that button never changes. But when I run the code, it gives the following error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element
The code is like this:
like_button = self.driver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/div/article/div[2]/section[1]/span[1]/button')
like_button.click()
But for some reason it doesn’t work
Have you ever given a Sleep() before the
find_element_by_xpath
? Just to make sure the page has loaded.– Edward Ramos
Yes, I’ve come to Aar a 20-second Sleep, but he still says it doesn’t exist
– Luis Meirelles