'"Unable to find element error" even if this exists
is there a way to click this "like" button? Because I can't do it via xpath or full xpath, not even using "webdriverwait". I always get the error Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='likebutton52335" class="div-center text-center']"} (Session info: chrome=100.0.4896.127)
even though I know it exists.
likebutton = driver.page_source
time.sleep(10)
#PRESS = re.findall('id="/html/body/div[9]/div/div/div/div[1]/div/div/div[4]/div/div[2]/div[2]/div[4]/div/div/div[1]/div[1]/span[5]"', likebutton, re.MULTILINE)
PRESS = re.findall('id="likebutton(.+?)"><a', likebutton, re.MULTILINE)
Solution 1:[1]
Your problem is inside your regex!
Actually your regex is configured to get:
id="(number"...)"<a
That explain this value for the regex in the error:
52335" class="div-center text-center']"
So you get other parameter from the HTML tag.
You need to change your regex by:
id="likebutton(.+?)"
Like that you get the content between doubles quotes.
Result:
likebutton = driver.page_source
time.sleep(3)
// This Line was modified
PRESS = re.findall('id="likebutton(.+?)"', likebutton, re.MULTILINE)
////////////////////////
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | WillyWhite |