Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- When I am trying to run this code one by one: I can run it without any error and login successfully
- Here is the code:
- import selenium
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.ui import Select
- from selenium.common.exceptions import NoSuchElementException
- baseurl = "http://www.gcrit.com/build3/admin/"
- username = "admin"
- password = "admin@123"
- xpaths = {'usernameTxtBox': '//input[@name="username"]', 'passwordTxtBox': '//input[@name="password"]', 'loginButton': '//button[@id="tdb1"]'}
- mydriver = webdriver.Chrome(executable_path=r"C:mypathForseleniumchromedriver.exe")
- mydriver.get(baseurl)
- mydriver.find_element_by_xpath(xpaths['usernameTxtBox']).send_keys(username)
- mydriver.find_element_by_xpath(xpaths['passwordTxtBox']).send_keys(password)
- mydriver.find_element_by_xpath(xpaths['loginButton']).click()
- My python file is saved in other file location. So I tried running the file in different ways
- I ran in this way: C:UsersmypathPython37python.exe "C:UsersmypathPythonScriptsSeleniumPractice.py"
- Received this error message "SyntaxError: unexpected character after line continuation character"
- 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