我在PyCharm中编写了基本的selenium unittest,当我运行它时,它说
" C:\ Python \ Python35 \ python.exe" C:\ Program Files(x86)\ JetBrains \ PyCharm Community Edition 2016.2.3 \ helpers \ pycharm \ utrunner.py" C:\ Python \ Projects \ Questionnaire.py是的 测试于22:20开始......
进程以退出代码0结束 空的测试套件。 "
我是Selenium的新手。请指导我如何从PyCharm运行
以下是我的代码:
from selenium import webdriver
import unittest, time
class questionnaire(unittest.TestCase):
@classmethod
def setUp(self):
self.driver = webdriver.Chrome()
def login(self):
driver = self.driver
driver.get("Site i want to access")
userid = driver.find_element_by_id("userIdInput")
userid.send_keys("R.vaidya")
password = driver.find_element_by_id("Password")
passphrase = "Admin$12345"
if passphrase == "Admin412345":
password.send_keys(passphrase)
submit = driver.find_element_by_id("login")
submit.click()
webelement = driver.find_element_by_xpath('/div/div/div/span')
text = webelement.text
Actaul = "Access Denied! The User Name or Password provided is incorrect or the user has not been set up. Please click on forgot password to reset your password."
self.assertCountEqual(Actaul,text,"Pass")
else:
password.send_keys(passphrase)
submit = driver.find_element_by_id("login")
submit.click()
time.sleep(3)
def tearDown(self):
driver = webdriver.Chrome()
driver.quit()
if __name__ == "__main__":
unittest.main()