遇到的坑-selenium报错:module selenium.webdriver has no attribute chrome

问题

今天实在是为了滚固自己之前的selenium知识,写了一个自动化邮件发送脚本,emmm,一切都是正常运行的,emm,结果我改了一下文件名(改为email.py),再运行,报错??????错误提示如下:
AttributeError: partially initialized module 'selenium.webdriver' has no attribute 'Chrome' (most likely due to a circular import)
emmmm,什么鬼

过程

我去网上百度了,也在stackoverflow找到了,根本无法解决额,emmm,重新安装selenium也不行额

解决

额,就是换一个名字就可以了,我是将email.py改为了email_163.py,好了…

源码部分

# -*-encoding:UTF-8 -*-
from selenium import webdriver
import time

web = webdriver.Chrome()
web.get('https://mail.163.com/')
iframe = web.find_element_by_tag_name('iframe')

web.switch_to_frame(iframe)

# 模拟登陆
account = input('你的邮箱账号:')
password = input('你的密码:')
address = input('收件人地址:')
topic = input('邮件主题:')
content = input('邮件内容:\n')
web.find_element_by_name('email').send_keys(account)
web.find_element_by_name('password').send_keys(password)
time.sleep(3)
web.find_element_by_id('dologin').click()

web.switch_to.default_content()
time.sleep(5)
# 写信
xx_butten = web.find_elements_by_xpath('//li[@hidefocus="hidefocus"]')[1].click()
time.sleep(5)
web.find_element_by_class_name('nui-editableAddr-ipt').send_keys(address)
zt = web.find_elements_by_class_name('nui-ipt-input')[2].send_keys(topic)
iframe = web.find_elements_by_tag_name('iframe')[3]

web.switch_to_frame(iframe)
time.sleep(1)
web.find_element_by_class_name('nui-scroll').send_keys(content)
web.switch_to.default_content()
time.sleep(1)
web.find_element_by_class_name('nui-toolbar-item').click()
web.quit()

你可能感兴趣的:(那些年遇到的坑,selenium)