0

I have installed selenium and I can run it on Python. When I try and run int on pyCharm I keep getting the errors below. I believe it may have to do with how and where I installed pyCharm, but I can't seem to get it to work. I am looking for help on how I should be configuring pyCharm so I can run my automation script using Python, Selenium, ChromeDriver, and set it up to be triggered every 24 hours and 5 minutes. script: from selenium import webdriver from selenium.webdriver.common.keys import 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()

I get the errors below.

"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
Roger Perez
  • 2,807
  • 29
  • 31
  • can you check path of chromedriver.exe ? can you try as raw string `r"D:\Projects\chromedriver.exe"` – Mahesh Karia Nov 03 '17 at 05:29
  • It seems to me some indentation issue, unnecessary white space on your code. Could you share the screenshot of your code if possible? – Shoaib Akhtar Nov 03 '17 at 05:34
  • Hi @MaheshKaria The chromedriver.exe is there. Copied and pasted – Roger Perez Nov 03 '17 at 05:34
  • And ensure there is no unnecessary white spaces in py file and I am not saying file is not there I am saying to replace `webdriver.Chrome("D:/Projects/chromedriver.exe")` with webdriver.Chrome(r"D:\Projects\chromedriver.exe") and check if it works. – Mahesh Karia Nov 03 '17 at 05:38
  • As per error message, it says EOL while scanning string literal...In case if you using long string then break it using \ at end and keep it in multiple line like str="some very long string.....\ .continue....\ ....end" Note-\ is given at end of line which is not arranged properly here – Shoaib Akhtar Nov 03 '17 at 05:42
  • Hi @MaheshKaria The chromedriver.exe is there. Copied and pasted r"D:\Projects\chromedriver.exe" Not sure if I can post screenshots on stackoverflow. [link] (https://github.com/rogercodes1/pyCharm/blob/master/chromewebdriver.JPG) – Roger Perez Nov 03 '17 at 05:43
  • @MaheshKaria I replaced the webdriver portion you mention and received the same errors. – Roger Perez Nov 03 '17 at 05:47

1 Answers1

0

You problem is below

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

and

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

Python has a internal module email and your Automation\email.py is overshadowing the same. Rename the file and it should work

Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265