Your issue is not necessarily your code 100%. It really depends on how you are hitting the site. The way I access IG is to login from another site. When I lick login to IG I get the IG popup. Then I need to:
-switch to the popup
-Login
-Handle all of the other questions
-then switch to main
You may need to tweak this based on what you are doing but this should work.
public void InstagramLogin()
{
Driver.FindElement(By.XPath("//button[@class='uppy-DashboardTab-btn']//div[contains(text(), 'Instagram')]")).Click();
Driver.FindElement(By.XPath("//button[contains(text(), 'Connect to Instagram')]")).Click();
Driver.SwitchToPopup();
Driver.WaitForElementDisplayed_byXPath("//input[@name='username']"));
Driver.FindElement(By.XPath("//input[@name='username']")).SendKeys("MyEmail@gmail.com");
Driver.FindElement(By.XPath("//input[@name='password']")).SendKeys("myPassword");
Driver.FindElement(By.XPath("//button[@type='submit']")).Click();
Driver.WaitForElementDisplayed(By.XPath("//button[text()='Not Now']"));
Driver.FindElement(By.XPath("//button[text()='Not Now']").Click();
bool ele = Driver.IsElementPresent(By.XPath("//button[contains(text(), 'Continue')]"));
if (ele)
{
Driver.FindElement(By.XPath("//button[contains(text(), 'Continue')]")).Click();
Driver.WaitForElementNoLongerDisplayed_byXPath("//button[contains(text(), 'Continue')]");
}
Driver.GoToMainHandle();
}