I tried to first locate (via xpath) and click the first post of a profile. Then I wanted to locate the "heart"-element and see the value of its aria-label because in the aria-label there is either "Like" or "Unlike". The problem is now that I get the following error when trying to locate the "heart"-element:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[4]/div[2]/div/article/div[3]/section[1]/span[1]/button/div/span/svg"}
I tried so much but somehow I am stuck at this simple problem... My code is:
def foo(self):
self.browser.find_element_by_xpath("/html/body/div[1]/section/main/div/div[3]/article/div[1]/div/div[1]/div[1]").click()
time.sleep(1)
element = self.browser.find_element_by_xpath("/html/body/div[4]/div[2]/div/article/div[3]/section[1]/span[1]/button/div/span/svg")
text = element.get_attribute("aria-label")
print(text)
I appriciate your help very much x)