class Jietu(): def __init__(self): self.driver = Qidong().driver def jietu(self): img_folder = os.path.abspath( os.path.join(os.path.dirname(__file__), "..")) + '//jietu//' time1 = time.strftime('%Y-%m-%d %H-%M-%S', time.localtime(time.time())) screen_save_path = img_folder + time1 + '.png' self.driver.get_screenshot_as_file(screen_save_path) pass
class Denglu(unittest.TestCase): def setUp(self): pass def tearDown(self): pass @classmethod def setUpClass(self): #启动app self.driver = Qidong().driver pass @classmethod def tearDownClass(self): pass def test_001(self): #添加截图方法 #点击耐克图标 # try: self.driver.find_element_by_id( "com.yougou:id/rl_toolbar_categories").click() self.driver.find_element_by_xpath( "/hierarchy/android.widget." "FrameLayout/android.widget." "LinearLayout/android.widget." "FrameLayout/android.widget.RelativeLayout/" "android.widget.LinearLayout/android.widget." "FrameLayout/android.widget.LinearLayout/android.widget." "LinearLayout/android.widget.LinearLayout/android.widget." "FrameLayout/android.widget.ListView/android.widget." "LinearLayout[2]/android.widget." "LinearLayout/android.widget.ListView/android.widget." "LinearLayout/android.widget.LinearLayout/android.widget." "LinearLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout" ).click()
class Denglu(unittest.TestCase): def setUp(self): pass def tearDown(self): pass @classmethod def setUpClass(self): #启动app Log().info(u"打开软件") self.driver=Qidong().driver pass @classmethod def tearDownClass(self): pass def test_001(self): Log().info(u"开始滑动") Shoushi().swipe_up(2) time.sleep(2) Log().info(u"点击商品") self.driver.find_element_by_id("com.yougou:id/imageView1").click() time.sleep(5) Log().info(u"点击去结算") self.driver.find_element_by_id("com.yougou:id/tv_buy_now").click() Log().info(u"选择颜色和大小") self.driver.find_elements_by_id("com.yougou:id/iv")[0].click() self.driver.find_elements_by_id("com.yougou:id/cs_size_tag_layout")[0].click() pass
class Denglu(unittest.TestCase): def setUp(self): pass def tearDown(self): pass @classmethod def setUpClass(self): #启动app Log().info(u"打开软件") self.driver = Qidong().driver pass @classmethod def tearDownClass(self): pass def test_001(self): self.driver.find_element_by_id("com.yougou:id/iv_101").click() time.sleep(2) a = self.driver.current_activity print a self.assertEqual(".activity.AHomeSecendActivity", a) pass def test_002(self): self.driver.back() self.driver.find_element_by_id("com.yougou:id/imageView1").click() a1 = self.driver.current_activity print a1 self.assertEqual(".activity.Html5Activity", a1) self.driver.find_element_by_id("signEvent").click() pass
def setUpClass(self): #启动app self.driver = Qidong().driver pass
def setUpClass(self): #启动app Log().info(u"打开软件") self.driver=Qidong().driver pass
def __init__(self): self.driver = Qidong().driver
class Shoushi(): def __init__(self): self.driver = Qidong().driver def swipe_up(self, n): s = self.driver.get_window_size() x1 = s['width'] * 0.5 # x坐标 y1 = s['height'] * 0.75 # 起点y坐标 y2 = s['height'] * 0.25 # 终点y坐标 for i in range(n): self.driver.swipe(x1, y1, x1, y2, duration=time.sleep(1)) # 向下滑动 def swipe_down(self, n): s = self.driver.get_window_size() x1 = s['width'] * 0.5 # x坐标 y1 = s['height'] * 0.25 # 起点y坐标 y2 = s['height'] * 0.75 # 终点y坐标 for i in range(n): self.driver.swipe(x1, y1, x1, y2, duration=time.sleep(1)) # 向左滑动 def swipe_left(self, n): s = self.driver.get_window_size() x1 = s['width'] * 0.75 y1 = s['height'] * 0.5 x2 = s['width'] * 0.25 for i in range(n): self.driver.swipe(x1, y1, x2, y1, duration=time.sleep(1)) # 向右 def swipe_right(self, n): l = self.driver.get_window_size() x1 = l['width'] * 0.25 y1 = l['height'] * 0.5 x2 = l['width'] * 0.75 for i in range(n): self.driver.swipe(x1, y1, x2, y1, duration=time.sleep(1)) # 获取当前activity的方法 def getCurrentActivity(self): return self.driver.current_activity
def setUpClass(self): #启动app Log().info(u"打开软件") self.driver=Qidong().driver time.sleep(2) pass