Guest User

Untitled

a guest
Sep 30th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. When I am trying to run this code one by one: I can run it without any error and login successfully
  2.  
  3. Here is the code:
  4. import selenium
  5. from selenium import webdriver
  6. from selenium.webdriver.common.by import By
  7. from selenium.webdriver.support.ui import Select
  8. from selenium.common.exceptions import NoSuchElementException
  9. baseurl = "http://www.gcrit.com/build3/admin/"
  10. username = "admin"
  11. password = "admin@123"
  12. xpaths = {'usernameTxtBox': '//input[@name="username"]', 'passwordTxtBox': '//input[@name="password"]', 'loginButton': '//button[@id="tdb1"]'}
  13. mydriver = webdriver.Chrome(executable_path=r"C:mypathForseleniumchromedriver.exe")
  14. mydriver.get(baseurl)
  15. mydriver.find_element_by_xpath(xpaths['usernameTxtBox']).send_keys(username)
  16. mydriver.find_element_by_xpath(xpaths['passwordTxtBox']).send_keys(password)
  17. mydriver.find_element_by_xpath(xpaths['loginButton']).click()
  18.  
  19. My python file is saved in other file location. So I tried running the file in different ways
  20.  
  21. I ran in this way: C:UsersmypathPython37python.exe "C:UsersmypathPythonScriptsSeleniumPractice.py"
  22. Received this error message "SyntaxError: unexpected character after line continuation character"
  23.  
  24. Also, I tried to run in the way mentioned in this link "https://stackoverflow.com/questions/33905824/how-to-run-py-files-in-command-prompt-windows-7" but it is not working properly.
Add Comment
Please, Sign In to add comment