Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Selenium启动后,Chrome会立即关闭 从selenium导入webdriver instaBot类: 定义初始化(自): self.driver=webdriver.Chrome() self.driver.get(“https://instagram.com") instaBot()_Python_Selenium_Google Chrome - Fatal编程技术网

Python 使用Selenium启动后,Chrome会立即关闭 从selenium导入webdriver instaBot类: 定义初始化(自): self.driver=webdriver.Chrome() self.driver.get(“https://instagram.com") instaBot()

Python 使用Selenium启动后,Chrome会立即关闭 从selenium导入webdriver instaBot类: 定义初始化(自): self.driver=webdriver.Chrome() self.driver.get(“https://instagram.com") instaBot(),python,selenium,google-chrome,Python,Selenium,Google Chrome,检查浏览器版本,确保启动chrome浏览器时没有兼容性问题,您可以下载 class bot: def __init__(self): self.driver = webdriver.Chrome(executable_path=r"C:\New folder\chromedriver.exe") def instagramLogin(self): driver = self.driver self.driver.get("htt

检查浏览器版本,确保启动chrome浏览器时没有兼容性问题,您可以下载

class bot:

    def __init__(self):
        self.driver = webdriver.Chrome(executable_path=r"C:\New folder\chromedriver.exe")

    def instagramLogin(self):
        driver = self.driver
        self.driver.get("https://instagram.com")

        WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.NAME, "username"))).send_keys("username")
        WebDriverWait( self.driver, 15).until(EC.presence_of_element_located((By.NAME, "password"))).send_keys("username")
        WebDriverWait( self.driver, 30).until(
            EC.element_to_be_clickable((By.XPATH, "//*[contains(text(), 'Log In')]"))).click()

        driver.close()

if __name__ == "__main__":
    bot = bot()
    bot.instagramLogin()       
注:

class bot:

    def __init__(self):
        self.driver = webdriver.Chrome(executable_path=r"C:\New folder\chromedriver.exe")

    def instagramLogin(self):
        driver = self.driver
        self.driver.get("https://instagram.com")

        WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.NAME, "username"))).send_keys("username")
        WebDriverWait( self.driver, 15).until(EC.presence_of_element_located((By.NAME, "password"))).send_keys("username")
        WebDriverWait( self.driver, 30).until(
            EC.element_to_be_clickable((By.XPATH, "//*[contains(text(), 'Log In')]"))).click()

        driver.close()

if __name__ == "__main__":
    bot = bot()
    bot.instagramLogin()       

检查浏览器版本,确保启动chrome浏览器时没有兼容性问题,您可以下载

class bot:

    def __init__(self):
        self.driver = webdriver.Chrome(executable_path=r"C:\New folder\chromedriver.exe")

    def instagramLogin(self):
        driver = self.driver
        self.driver.get("https://instagram.com")

        WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.NAME, "username"))).send_keys("username")
        WebDriverWait( self.driver, 15).until(EC.presence_of_element_located((By.NAME, "password"))).send_keys("username")
        WebDriverWait( self.driver, 30).until(
            EC.element_to_be_clickable((By.XPATH, "//*[contains(text(), 'Log In')]"))).click()

        driver.close()

if __name__ == "__main__":
    bot = bot()
    bot.instagramLogin()       
注:

class bot:

    def __init__(self):
        self.driver = webdriver.Chrome(executable_path=r"C:\New folder\chromedriver.exe")

    def instagramLogin(self):
        driver = self.driver
        self.driver.get("https://instagram.com")

        WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.NAME, "username"))).send_keys("username")
        WebDriverWait( self.driver, 15).until(EC.presence_of_element_located((By.NAME, "password"))).send_keys("username")
        WebDriverWait( self.driver, 30).until(
            EC.element_to_be_clickable((By.XPATH, "//*[contains(text(), 'Log In')]"))).click()

        driver.close()

if __name__ == "__main__":
    bot = bot()
    bot.instagramLogin()       

您好,我已经编辑了您的问题,添加了一些python代码格式,使其更具可读性。您只需打开一个URL并返回。您可以尝试将
睡眠
放在
驱动程序之后。如果您只想验证页面是否正在加载,请获取
。另外,不要在构造函数中这样做,为它编写一个方法。明白了,伙计们谢谢你们,我已经编辑了你们的问题,添加了一些python代码格式,使其更可读。你们只是打开一个URL并返回。您可以尝试将
睡眠
放在
驱动程序之后。如果您只想验证页面是否正在加载,请获取
。此外,不要在构造函数中这样做,为此编写一个方法。明白了,伙计们,谢谢