Skip to content

Commit

Permalink
fix: crash during followers list focus
Browse files Browse the repository at this point in the history
fix: now check for the second cookies prompt after login (not always present)
  • Loading branch information
hbollon committed Oct 26, 2021
1 parent a20c0eb commit d020662
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 9 additions & 0 deletions actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ func (bot *IGopher) connectToInstagramWebDriver() {
bot.SeleniumStruct.Fatal("Log in button not found: ", err)
}
randomSleepCustom(10, 15)
// Accept second cookies prompt if requested
if find, err := bot.SeleniumStruct.WaitForElement("//button[text()='Allow All Cookies']", "xpath", 10); err == nil && find {
elem, _ := bot.SeleniumStruct.GetElement("//button[text()='Allow All Cookies']", "xpath")
elem.Click()
log.Debug("Second cookies validation done!")
randomSleep()
} else {
log.Info("Second cookies validation button not found, skipping.")
}
// Check if login was successful
if bot.SeleniumStruct.IsElementPresent(selenium.ByXPATH,
"//*[@aria-label='Home'] | //button[text()='Save Info'] | //button[text()='Not Now']") {
Expand Down
9 changes: 0 additions & 9 deletions scrapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@ func (sc *IGopher) navigateUserFollowersList(srcUsername string) (bool, error) {
} else {
return true, errors.New("Error during access to user followers list")
}
randomSleepCustom(1, 3)
// Focus list
if find, err := sc.SeleniumStruct.WaitForElement("//*[@id=\"react-root\"]/section/main/div", "xpath", 10); err == nil && find {
dialog, _ := sc.SeleniumStruct.GetElement("//*[@id=\"react-root\"]/section/main/div", "xpath")
dialog.Click()
logrus.Debug("Clicked on user followers dialog box")
} else {
return true, errors.New("Error during focus user followers list dialog")
}

return true, nil
}

0 comments on commit d020662

Please sign in to comment.