Instagram Login page not loading on Heroku using selenium with chromedriver

Viewed 187

I am trying to login to Instagram using selenium and chromedriver. Driver is able to open login page and enter username and password and login is successful on my local macOS machine. But when I deploy it to Heroku, it says NoSuchElement on username field.

Here is my code.

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-agent=Mozilla/5.0 (X11; Ubuntu; Linux armv7l; rv:17.0) Gecko/20100101 Firefox/17.0")
driver_path = ChromeDriverManager().install()
driver = webdriver.Chrome(driver_path, chrome_options=chrome_options)
driver.implicitly_wait(60)

driver.get('https://www.instagram.com/')
username_input = WebDriverWait(browser, 60).until(EC.visibility_of_element_located((By.XPATH, "//input[@name='username']")))
password_input = browser.find_element_by_css_selector("input[name='password']")

username_input.send_keys("test")
password_input.send_keys("test")

login_button = browser.find_element_by_xpath("//button[@type='submit']")
login_button.click()

I tracked my requests using seleniumwire and earlier opening Instagram login url was giving 301 but after adding user agent I am now getting 200 for Instagram login url.

But now it fails on finding the username input field.

PS - This is working fine on Local macOS machine but not working on Heroku

0 Answers
Related