pyCharm Selenium Python eol扫描字符串时

时间:2017-11-03 05:23:52

标签: python selenium selenium-webdriver pycharm chrome-web-driver

我已经安装了selenium,我可以在Python上运行它。 当我尝试在pyCharm上运行int时,我不断收到以下错误。我相信它可能与我安装pyCharm的方式和位置有关,但我似乎无法让它工作。 我正在寻找有关如何配置pyCharm的帮助,以便我可以使用Python,Selenium,ChromeDriver运行我的自动化脚本,并将其设置为每24小时5分钟触发一次。     脚本:     来自selenium import webdriver     来自selenium.webdriver.common.keys导入密钥

browser= webdriver.Chrome("D:/Projects/chromedriver.exe")
browser.get("https://url.com/")

formElem= browser.find_element_by_name('email')
formElem.send_keys('ucsb@gmail.com')

zipElem=browser.find_element_by_name('zipcode')

zipElem.send_keys('93101')

EnterNowElem=browser.find_element_by_xpath('//input[@value="Enter Now"]')

#EnterTagElem=browser.find_element_by_class_name("")
EnterNowElem.click()

我收到以下错误。

"C:\Program Files (x86)\Python36-32\python.exe" 
C:/Users/rxper/Desktop/PycharmProjects/Automation/formsubmit.py
Traceback (most recent call last):
  File "C:/Users/rxper/Desktop/PycharmProjects/Automation/formsubmit.py", line 1, in <module>
   from selenium import webdriver

 File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
   from .firefox.webdriver import WebDriver as Firefox  # noqa
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 19, in <module>
   import http.client as http_client
File "C:\Program Files (x86)\Python36-32\lib\http\client.py", line 71, in <module>
   import email.parser
File "C:\Users\rxper\Desktop\PycharmProjects\Automation\email.py", line 31
'Subject: So long.\nDear Alice, so long and thanks for all the fish. Sincerely,

^
SyntaxError: EOL while scanning string literal

Process finished with exit code 1

1 个答案:

答案 0 :(得分:0)

你的问题在

之下
File "C:\Users\rxper\Desktop\PycharmProjects\Automation\email.py"

File "C:\Program Files (x86)\Python36-32\lib\http\client.py", line 71, in <module>
   import email.parser

Python有一个内部模块email,而你的Automation\email.py却黯然失色。重命名文件,它应该工作