SimpleInstaBot icon indicating copy to clipboard operation
SimpleInstaBot copied to clipboard

Failed to find unfollow button

Open stefpriols opened this issue 4 years ago • 6 comments

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

stefpriols avatar Jul 11 '21 14:07 stefpriols

Schermata 2021-07-20 alle 14 47 41

stefpriols avatar Jul 20 '21 12:07 stefpriols

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?

mifi avatar Jul 23 '21 08:07 mifi

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?

unfollow button dev tools

stefpriols avatar Jul 27 '21 15:07 stefpriols

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

mifi avatar Jul 29 '21 14:07 mifi

<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>

stefpriols avatar Aug 02 '21 15:08 stefpriols

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...

mifi avatar Aug 04 '21 07:08 mifi