示例#1
0
 def test_order_submit(self):
     #下滑滚动条
     #for i in (0,28):
     action = ActionChains(self.driver).move_to_element(
         self.driver.find_element_by_id("keyval"))
     action.send_keys(Keys.ARROW_DOWN)  #点击键盘向下箭头
     time.sleep(3)
     #获取当前窗口句柄
     nowhandle = self.driver.current_window_handle
     #点击纪念币楼层第一行第4个商品
     IndexPage().click_goods14_link().click()
     time.sleep(3)
     #获取所有handle
     allhandles = self.driver.window_handles
     #循环,当句柄不等于首页句柄时,转换为现在的窗口句柄
     for handle in allhandles:
         if handle != nowhandle:
             self.driver.switch_to_window(handle)
     #点击立即购买
     GoodsDetail().click_buy_id().click()
     time.sleep(1)
     #滑动滚动条
     CommonDef().huadong_gundongtiao()
     #点击提交订单
     OrderSubmitPage().click_order_submit().click()
     time.sleep(1)
示例#2
0
文件: Login.py 项目: pylk/jinbi
 def test03(self):
     mylogger.debug("执行用例:用户名30位,判断最多输入30位")
     #输入用户名
     username = ReadExcelData().returnExcelData('data.xlsx', 'login', 4, 1)
     username2 = ReadExcelData().returnExcelData('data.xlsx', 'login', 4, 3)
     LoginPage().click_username().send_keys(username)
     time.sleep(2)
     try:
         username1 = self.driver.find_elements_by_tag_name(
             'input')[0].get_attribute('value')
         self.assertEqual(username1, username2)
         mylogger.debug("test03执行结果:成功")
     except Exception as e:
         mylogger.debug("test03执行结果:失败")
         mylogger.debug(e)
         CommonDef().get_windows_img("img_test03")
示例#3
0
文件: Login.py 项目: pylk/jinbi
 def test10(self):
     mylogger.debug("执行用例:密码输入20位")
     password = ReadExcelData().returnExcelData('data.xlsx', 'login', 11, 2)
     password2 = ReadExcelData().returnExcelData('data.xlsx', 'login', 11,
                                                 3)
     LoginPage().click_password().send_keys(password)
     time.sleep(2)
     try:
         password1 = self.driver.find_elements_by_tag_name(
             'input')[1].get_attribute('value')
         self.assertEqual(password1, password2)
         mylogger.debug("test10执行结果:成功")
     except Exception as e:
         mylogger.debug("test10执行结果:失败")
         mylogger.debug(e)
         CommonDef().get_windows_img("img_test10")
示例#4
0
文件: Login.py 项目: pylk/jinbi
 def test01(self):
     mylogger.debug("执行用例:用户名为空,密码正确")
     #输入用户名
     username = ReadExcelData().returnExcelData('data.xlsx', 'login', 2, 1)
     LoginPage().click_username().send_keys(username)
     #输入密码
     password = ReadExcelData().returnExcelData('data.xlsx', 'login', 2, 2)
     LoginPage().click_password().send_keys(password)
     #点击登录按钮
     LoginPage().click_login_submit().click()
     time.sleep(5)
     try:
         error = self.driver.find_element_by_class_name("error").text
         self.assertEqual(error, u"请输入注册手机号/会员账号")
         mylogger.debug("test01执行结果:成功")
     except Exception as e:
         mylogger.debug("test01执行结果:失败")
         mylogger.debug(e)
         CommonDef().get_windows_img("img_test01")
示例#5
0
文件: Login.py 项目: pylk/jinbi
 def test04(self):
     mylogger.debug("执行用例:用户名前有空格")
     #输入用户名
     username = ReadExcelData().returnExcelData('data.xlsx', 'login', 5, 1)
     LoginPage().click_username().send_keys(username)
     #输入密码
     password = ReadExcelData().returnExcelData('data.xlsx', 'login', 5, 2)
     LoginPage().click_password().send_keys(password)
     #点击登录按钮
     LoginPage().click_login_submit().click()
     time.sleep(5)
     #判断是否登录成功
     try:
         username2 = self.driver.find_element_by_partial_link_text(
             username.strip()).text
         self.assertEqual(username2, username.strip(), "登录成功")
         mylogger.debug("test04执行结果:成功")
     except Exception as e:
         mylogger.debug("test04执行结果:失败")
         mylogger.debug(e)
         CommonDef().get_windows_img("img_test04")
示例#6
0
文件: Login.py 项目: pylk/jinbi
 def test08(self):
     mylogger.debug("执行用例:密码错误")
     #输入用户名
     username = ReadExcelData().returnExcelData('data.xlsx', 'login', 9, 1)
     LoginPage().click_username().send_keys(username)
     #输入密码
     password = ReadExcelData().returnExcelData('data.xlsx', 'login', 9, 2)
     LoginPage().click_password().send_keys(password)
     time.sleep(2)
     #点击登录按钮
     LoginPage().click_login_submit().click()
     time.sleep(3)
     try:
         error = self.driver.find_element_by_class_name("error").text
         excError = ReadExcelData().returnExcelData('data.xlsx', 'login', 9,
                                                    3)
         self.assertEqual(error, excError)
         mylogger.debug("test08执行结果:成功")
     except Exception as e:
         mylogger.debug("test08执行结果:失败")
         mylogger.debug(e)
         CommonDef().get_windows_img("img_test08")
示例#7
0
 def test01(self):
     mylogger.debug("开始编辑地址")
     #点击编辑
     mylogger.debug("点击编辑")
     try:
         AddressPage().click_edit_address().click()
     except Exception:
         assert False, "未能成功点击编辑按钮"
     self.driver.implicitly_wait(5)
     #清空收货人原有内容
     mylogger.debug("清空收货人原有内容")
     AddressPage().input_edit_name_id().clear()
     try:
         AddressPage().input_edit_name_id().clear()
     except Exception:
         assert False, "未能成功清空收货人原有信息"
     time.sleep(4)
     #编辑收货人
     mylogger.debug("编辑收货人")
     try:
         edit_name = ReadExcelData().returnExcelData(
             'data.xlsx', 'address', 0, 1)
         AddressPage().input_edit_name_id().send_keys(edit_name)
     except Exception:
         assert False, "未能成功编辑收货人"
     self.driver.implicitly_wait(5)
     #选择地址_省
     mylogger.debug("选择地址_省")
     try:
         AddressPage().select_edit_province_id().click()
     except Exception:
         assert False, "未能成功选择地址_省"
     time.sleep(2)
     #选择地址_市
     mylogger.debug("选择地址_市")
     try:
         AddressPage().select_edit_city_id().click()
     except Exception:
         assert False, "未能成功选择地址_省"
     time.sleep(2)
     #选择地址_区
     mylogger.debug("选择地址_区")
     try:
         AddressPage().select_edit_county_id().click()
     except Exception:
         assert False, "未能成功选择地址_区"
     time.sleep(2)
     #清空详细地址原有内容
     mylogger.debug("清空详细地址原有内容")
     try:
         AddressPage().input_edit_detailaddress_id().clear()
     except Exception:
         assert False, "未能成功清空详细地址原有内容"
     #编辑详细地址
     mylogger.debug("编辑详细地址")
     try:
         edit_address = ReadExcelData().returnExcelData(
             'data.xlsx', 'address', 1, 1)
         AddressPage().input_edit_detailaddress_id().send_keys(edit_address)
     except Exception:
         assert False, "未能成功编辑详细地址"
     self.driver.implicitly_wait(5)
     #清空手机号原有内容
     mylogger.debug("清空手机号原有内容")
     try:
         AddressPage().input_edit_mobile_id().clear()
     except Exception:
         assert False, "未能成功清空手机号原有内容"
     #编辑手机号
     mylogger.debug("编辑手机号")
     try:
         edit_mobile = ReadExcelData().returnExcelData(
             'data.xlsx', 'address', 2, 1)
         AddressPage().input_edit_mobile_id().send_keys(str(edit_mobile))
     except Exception:
         assert False, "未能成功编辑手机号"
     time.sleep(5)
     #截屏
     CommonDef().get_windows_img()
     #点击保存收货地址
     mylogger.debug("点击保存收货地址")
     # JavascriptExecutor executor = (JavascriptExecutor) driver;
     # executor.executeScript("arguments[0].click();",AddressPage().click_edit_button());
     try:
         AddressPage().click_edit_button().click()
     except Exception:
         assert False, "未能成功点击确认修改按钮"
     time.sleep(2)
     #截屏
     CommonDef().get_windows_img()
     time.sleep(2)
示例#8
0
 def test02(self):
     mysql_host = ReadExcelData().returnExcelData('data.xlsx', 'mysql', 0,
                                                  1)
     mysql_user = ReadExcelData().returnExcelData('data.xlsx', 'mysql', 1,
                                                  1)
     mysql_password = ReadExcelData().returnExcelData(
         'data.xlsx', 'mysql', 2, 1)
     mysql_port = ReadExcelData().returnExcelData('data.xlsx', 'mysql', 3,
                                                  1)
     mysql_database = ReadExcelData().returnExcelData(
         'data.xlsx', 'mysql', 4, 1)
     _sql1 = ReadExcelData().returnExcelData('data.xlsx', 'mysql', 6, 1)
     _sql2 = ReadExcelData().returnExcelData('data.xlsx', 'mysql', 7, 1)
     count = MysqlConnection().count_mysql(mysql_host, int(mysql_port),
                                           mysql_user, mysql_password,
                                           mysql_database, "utf8", _sql1)
     print count[0]
     time.sleep(3)
     if count[0] == 10:
         MysqlConnection().del_mysql(mysql_host, int(mysql_port),
                                     mysql_user, mysql_password,
                                     mysql_database, "utf8", _sql2)
     else:
         pass
     time.sleep(3)
     count = MysqlConnection().count_mysql(mysql_host, int(mysql_port),
                                           mysql_user, mysql_password,
                                           mysql_database, "utf8", _sql1)
     print count[0]
     mylogger.debug("开始新增地址")
     #点击新增
     AddressPage().click_add_address_class().click()
     time.sleep(3)
     #输入收货人
     add_name = ReadExcelData().returnExcelData('data.xlsx', 'address', 3,
                                                1)
     AddressPage().click_add_name().send_keys(add_name)
     self.driver.implicitly_wait(5)
     mylogger.debug("输入收货人")
     #选择省
     AddressPage().click_add_province().click()
     time.sleep(2)
     mylogger.debug("选择省")
     #选择市
     AddressPage().click_add_city().click()
     time.sleep(2)
     mylogger.debug("选择市")
     #选择区
     AddressPage().click_add_county().click()
     time.sleep(2)
     mylogger.debug("选择区")
     #S输入详细地址
     add_address = ReadExcelData().returnExcelData('data.xlsx', 'address',
                                                   4, 1)
     AddressPage().click_add_detailaddress().send_keys(add_address)
     self.driver.implicitly_wait(5)
     mylogger.debug("输入详细地址")
     #输入手机号
     add_mobile = ReadExcelData().returnExcelData('data.xlsx', 'address', 5,
                                                  1)
     AddressPage().click_add_mobile().send_keys(str(add_mobile))
     self.driver.implicitly_wait(5)
     self.driver.implicitly_wait(5)
     mylogger.debug("输入手机号")
     #点击提交按钮
     AddressPage().click_add_button().click()
     self.driver.implicitly_wait(5)
     mylogger.debug("点击提交按钮")
     #截屏
     CommonDef().get_windows_img()
     # CreateConnectionMysql().connection_mysql(mysql_host,int(mysql_port),mysql_user,mysql_password,mysql_database,"utf8")
     # CreateConnectionMysql().cureors() #数据库游标
     _sql = ReadExcelData().returnExcelData('data.xlsx', 'mysql', 5, 1)
     MysqlConnection().connection_mysql(mysql_host, int(mysql_port),
                                        mysql_user, mysql_password,
                                        mysql_database, "utf8", _sql)
示例#9
0
 def tearDown(self):
     CommonDef().quit()
示例#10
0
 def setUp(self):
     self.driver = GetSeleniumDriver().driver
     CommonDef().login(u"http://pftest.ecgci.com/index.html", u"test0135",
                       u"aaaaaa")