没有网络驱动程序的Python自动浏览器

时间:2019-11-12 14:32:05

标签: python selenium google-chrome webdriver

我有这段代码,它会打开chrome,但它不想继续使用该代码。真的不知道如何解决该问题。我不希望它打开Selenium WebDriver,不希望它打开我自己的本地chrome路径,我希望同时使脚本读取读取的元素并打印值。

Error picture

import names, time, random
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC




def AccGen():
        while True:

            # *************Static***************
            prefs = {"profile.managed_default_content_settings.images": 1}
            options = Options()
            # options.add_argument('--disable-gpu')
            # options.add_argument("--disable-extensions")
            # options.add_argument('--disable-notifications')
            options.add_experimental_option("prefs", prefs)
            options.add_argument("--window-size=1600,900")
            browser = webdriver.Chrome(executable_path='C:/Users/Jonathan/AppData/Local/Google/Chrome/Application/Chrome.exe',chrome_options=options)
            browser.implicitly_wait(10)

            # ------------------------------------

            # Access to site
            browser.get(
                "https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ltmpl=default"
            )

            ###################################################################

            firstName = names.get_first_name()
            lastName = names.get_last_name()
            email = '{}.{}{}'.format(firstName, lastName, random.randint(1000, 9999))
            password = '2001jl00'

            ###################################################################
            # Write in random Name
            WebDriverWait(browser, 20).until(
                EC.visibility_of_element_located(
                    (By.XPATH, '//*[@id="firstName"]'))).send_keys(firstName)

https://mystb.in/vevivuneku.coffeescript

0 个答案:

没有答案