# -*- coding: utf-8 -*-
__author__ = 'EX-PENGFEI913'
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
from common import Login,Logout
from common import Location
class Sms(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
url="https://permission.st.anhouse.com.cn/site/login.html?referer=aHR0cDovL3NlcnZpY2Utc21zLnN0MTAuYW5ob3VzZS5jb20uY24vbWFuYWdlL3VzZXIvbG9naW4uaHRtbD9mcm9tX21vX3R5cGU9cHVibGlzaA=="
self.base_url = url
self.verificationErrors = []
self.accept_next_alert = True
def test_sms(self):
driver = self.driver
we = Location
u"""短信系统登录"""
driver.get(self.base_url + "/site/login.html?referer=aHR0cDovL3NlcnZpY2Utc21zLnN0MTAuYW5ob3VzZS5jb20uY24vbWFuYWdlL3VzZXIvbG9naW4uaHRtbD9mcm9tX21vX3R5cGU9cHVibGlzaA==")
Login.login(self)
we.findLinkText(driver,u"短信测试").click()
Select(we.findId(driver,"channel")).select_by_visible_text("95511new")
we.findId(driver,"mobile").clear()
we.findId(driver,"mobile").send_keys("18818036169")
we.findId(driver,"templateid").clear()
we.findId(driver,"templateid").send_keys("HF170117002")
we.findId(driver,"params").clear()
we.findId(driver,"params").send_keys(u"house=湾流国际青年社区女神店&time=2017-03-29 00:00&link=http://suo.im/3GBUpQ")
we.findId(driver,"btnSend").click()
we.findId(driver,"btnFinish").click()
we.findLinkText(driver,u"短信查询").click()
we.findId(driver,"mobile").clear()
we.findName(driver,"mobile").send_keys("18818036169")
we.findXpath(driver,"//button[@type='submit']").click()
Logout.logout(self)
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
"""
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException as e: return False
return True
def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException as e: return False
return True
def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
"""
if __name__ == "__main__":
unittest.main()
suite = unittest.TestSuite()
suite.addTest(Sms("test_sms_report"))
#同样的,可以在这个文件中添加更多的用例。
#suite.addTest(Youdao("aaaa"))
results = unittest.TextTestRunner().run(suite)
__author__ = 'EX-PENGFEI913'
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
from common import Login,Logout
from common import Location
class Sms(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
url="https://permission.st.anhouse.com.cn/site/login.html?referer=aHR0cDovL3NlcnZpY2Utc21zLnN0MTAuYW5ob3VzZS5jb20uY24vbWFuYWdlL3VzZXIvbG9naW4uaHRtbD9mcm9tX21vX3R5cGU9cHVibGlzaA=="
self.base_url = url
self.verificationErrors = []
self.accept_next_alert = True
def test_sms(self):
driver = self.driver
we = Location
u"""短信系统登录"""
driver.get(self.base_url + "/site/login.html?referer=aHR0cDovL3NlcnZpY2Utc21zLnN0MTAuYW5ob3VzZS5jb20uY24vbWFuYWdlL3VzZXIvbG9naW4uaHRtbD9mcm9tX21vX3R5cGU9cHVibGlzaA==")
Login.login(self)
we.findLinkText(driver,u"短信测试").click()
Select(we.findId(driver,"channel")).select_by_visible_text("95511new")
we.findId(driver,"mobile").clear()
we.findId(driver,"mobile").send_keys("18818036169")
we.findId(driver,"templateid").clear()
we.findId(driver,"templateid").send_keys("HF170117002")
we.findId(driver,"params").clear()
we.findId(driver,"params").send_keys(u"house=湾流国际青年社区女神店&time=2017-03-29 00:00&link=http://suo.im/3GBUpQ")
we.findId(driver,"btnSend").click()
we.findId(driver,"btnFinish").click()
we.findLinkText(driver,u"短信查询").click()
we.findId(driver,"mobile").clear()
we.findName(driver,"mobile").send_keys("18818036169")
we.findXpath(driver,"//button[@type='submit']").click()
Logout.logout(self)
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
"""
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException as e: return False
return True
def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException as e: return False
return True
def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
"""
if __name__ == "__main__":
unittest.main()
suite = unittest.TestSuite()
suite.addTest(Sms("test_sms_report"))
#同样的,可以在这个文件中添加更多的用例。
#suite.addTest(Youdao("aaaa"))
results = unittest.TextTestRunner().run(suite)