0

我已经安装了 selenium,我可以在 Python 上运行它。当我尝试在 pyCharm 上运行 int 时,我不断收到以下错误。我相信这可能与我安装 pyCharm 的方式和位置有关,但我似乎无法让它工作。我正在寻求有关如何配置 pyCharm 的帮助,以便我可以使用 Python、Selenium、ChromeDriver 运行我的自动化脚本,并将其设置为每 24 小时 5 分钟触发一次。脚本:从 selenium 导入 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
4

1 回答 1

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也掩盖了它。重命名文件,它应该可以工作

于 2017-11-03T06:21:53.433 回答