Reputation: 3885
I want to log in to Instagram with selenium webdriber. I wrote a code but It always opens just google chrome page, without going to Instagram page. I have tried to change to .sleep()
time but It is always the same.
from selenium import webdriver
import time
class InstagramBot:
def __init__(self, username, password):
self.username = username
self.password = password
self.driver = webdriver.Chrome(executable_path = "C:\Program Files (x86)\xxx\xxx\xxx\chrome.exe")
def closeBrowser(self):
self.driver.close()
def login(self):
driver = self.driver
driver.get("https://www.instagram.com/")
time.sleep(5)
IGBot = InstagramBot("xxx", "yyy")
IGBot.login()
Also I have tried with \chrome.exe
and with \chrome
, and with "www.instagram.com".
After 5 seconds, I get this error:
selenium.common.exceptions.WebDriverException: Message: Service C:\Program Files (x86)\xxx\xxx\xxxx\chrome.exe unexpectedly exited. Status code was: 0
Upvotes: 0
Views: 161
Reputation: 3503
This line
self.driver = webdriver.Chrome(executable_path = "C:\Program Files (x86)\xxx\xxx\xxx\chrome.exe")
should be
self.driver = webdriver.Chrome(executable_path = "C:\complete\path\to\chromedriver.exe")
Note not to confuse "chrome.exe" with "chromedriver.exe" in Selenium context.
Upvotes: 2