SimpleInstaBot
SimpleInstaBot copied to clipboard
Failed to find unfollow button
Hi, Bot keeps failing to find unfollow button. How can I fix it?

could you take a screenshot of how the unfollow button looks like? Or open developer tools and highlight it and show how it looks like in the Elements tab?
could you take a screenshot of how the unfollow button looks like? Or open developer tools and highlight it and show how it looks like in the Elements tab?

That is strange. It seems like the button is missing an aria-label? it should be <button aria-label="Following" ....
The code here:
https://github.com/mifi/instauto/blob/c5b0fffa739eaebe5178475c96e4409c1173e8ba/index.js#L218
async function findUnfollowButton() {
const elementHandles = await page.$x("//header//button[text()='Following']");
if (elementHandles.length > 0) return elementHandles[0];
const elementHandles2 = await page.$x("//header//button[text()='Requested']");
if (elementHandles2.length > 0) return elementHandles2[0];
const elementHandles3 = await page.$x("//header//button[*//span[@aria-label='Following']]");
if (elementHandles3.length > 0) return elementHandles3[0];
return undefined;
}
I'm not sure how to identify the unfollow button if it doesn't have a text or aria label.
One last thing you could try for me is to copy the HTML of the button (or even better the whole page) and share it, by following these instructions:
Using the Web Inspector (F12), go to the Elements tab, right click on the tag in your code and select Copy->Copy outerHTML. Then paste that here
<button class="_5f5mN -fzfL _6VtSN yZn4P "><div class=" Igw0E rBNOH YBx95 _4EzTm " style="height: 28px;"><span aria-label="Following" class="glyphsSpriteFriend_Follow u-__7"></span></div></button>
Thanks. The code page.$x("//header//button[*//span[@aria-label='Following']]"); will indeed match your button. Then I honestly don't know what happened there...