def swipe(self, direction): touch = TouchActions(self) touch.flick( self.FlickSpeeds[direction][0], self.FlickSpeeds[direction][1] ) touch.perform()
def touchaction_scrollbottom(self, ele): ''' 使用 TouchActions 实现界面滑动到底部 :param ele: ''' action = TouchActions(self.driver) action.scroll_from_element(ele, 0, 10000) action.perform()
def test_touchaction(self): self.driver.get('http://www.baidu.com') ele = self.driver.find_element_by_id('kw') ele.send_keys('selenium测试') action = TouchActions(self.driver) ele_search = self.driver.find_element_by_id('su') action.tap(ele_search) action.perform() action.scroll_from_element(ele_search, 0, 10000).perform()
def test_touchAction(self): self.driver.get("https://www.baidu.com") element1 = self.driver.find_element(By.ID, "kw") element1.send_keys("selenium测试") element2 = self.driver.find_element(By.ID, 'su') action = TouchActions(self.driver) action.tap(element2) action.scroll_from_element(element1, 0, 10000) action.perform()
def test_touch_action(self): self.driver.get("http://www.baidu.com") ele=self.driver.find_element_by_id("kw").send_keys('selenium测试') ele_click=self.driver.find_element_by_id("su") action = TouchActions(self.driver) action.tap(ele_click) action.perform() action.scroll_from_element(ele_click,0,10000).perform() sleep(3)
def test_touch(self): self.driver.get("https://www.baidu.com/") self.driver.find_element(By.XPATH, "//*[@id='kw']").send_keys("selenium_3") ele = self.driver.find_element(By.XPATH, "//*[@id='su']") action = TouchActions(self.driver) action.tap(ele) action.perform() action.scroll_from_element(ele, 0, 10000).perform() sleep(3)
def test_TouchAction(self): self.driver.get('http://www.baidu.com') element_input = self.driver.find_element_by_id("kw") element_search = self.driver.find_element_by_id("su") action = TouchActions(self.driver) element_input.send_keys("selenium测试") action.tap(element_search) action.perform() #将页面向下滚动,需要三个参数, action.scroll_from_element(element_input, 0, 10000).perform()
def test_touchaction_scrollbotton(self): self.driver.get("https://www.baidu.com") el = self.driver.find_element_by_id("kw") el_search = self.driver.find_element_by_id("su") el.send_keys("selenium 测试") action = TouchActions(self.driver) action.tap(el_search) action.scroll_from_element(el, 0, 1000) action.perform() sleep(3)
def test_touchaction_scrollbottom(self): self.driver.get("https://www.baidu.com") el = self.driver.find_element_by_id("kw") #定位到输入框 el_search = self.driver.find_element_by_id("su") #定位到百度一下 el.send_keys("selenium测试") #输入 action = TouchActions(self.driver) action.tap(el_search) #点击 action.scroll_from_element(el, 0, 10000) #从搜索框这个元素开始向下滑动 action.perform() sleep(3)
def test_touch_action(self): self.driver.get("https://www.baidu.com/") ele_input = self.driver.find_element_by_id("kw") ele_search = self.driver.find_element_by_id("su") action = TouchActions(self.driver) ele_input.send_keys("selenium测试") # TouchActions的点击操作 action.tap(ele_search) action.perform() action.scroll_from_element(ele_input, 0, 10000).perform()
def test_grid(self): self.driver.get("https://www.baidu.com/") el = self.driver.find_element_by_id('kw') el_search = self.driver.find_element_by_id('su') el.send_keys('selenium测试') action = TouchActions(self.driver) action.tap(el_search) # 点击 action.perform() action.scroll_from_element(el, 0, 10000).perform() time.sleep(5)
def scroll(self, to_y=2000): """ 滑动页面 :return: """ elem = self.get_element() action = TouchActions(self.driver) action.scroll_from_element(elem, 0, to_y) action.perform() sleep(2)
def test_action(self): self.driver.get('http://www.baidu.com') el = self.driver.find_element(By.ID, 'kw') el_search = self.driver.find_element(By.ID, 'su') el.send_keys('selenium测试') action = TouchActions(self.driver) action.tap(el_search) action.perform() action.scroll_from_element(el, 0, 10000).perform()
def test_touch_action_scroll(self): self.driver.get("https://www.baidu.com") elem = self.driver.find_element(By.ID, 'kw') ele_search = self.driver.find_element(By.ID, 'su') elem.send_keys("selenium测试") action = TouchActions(self.driver) action.tap(ele_search) action.perform() action.scroll_from_element(elem, 0, 10000).perform() sleep(5)
def test_touchaction_scrollbottom(self, ): # 使用 TouchActions 实现界面的滑动到底端 self.driver.get("https://www.baidu.com") inputele = self.driver.find_element_by_xpath('//*[@id="kw"]') searchele = self.driver.find_element_by_id("su") inputele.send_keys("username") action = TouchActions(self.driver) action.tap(searchele) action.perform() action.scroll_from_element(inputele, 0, 10000).perform() sleep(6)
def test_touchactions_scroll(self): self.driver.get('https://www.baidu.com/') searchelement = self.driver.find_element(By.ID, 'kw') searchelement.send_keys('selenium官网') self.driver.find_element(By.ID, 'su').click() sleep(2) action = TouchActions(self.driver) action.scroll_from_element(searchelement, 0, 10000) sleep(2) action.perform()
def test_touch(self): el = self.driver.find_element_by_id('kw') el_search = self.driver.find_element_by_id('su') el.send_keys('selenium测试') action = TouchActions(self.driver) action.tap(el_search) action.perform() action.scroll_from_element(el_search, 0, 10000).perform() time.sleep(3)
def test_baidu(self): """滑动""" self.driver.get("https://www.baidu.com/") el = self.driver.find_element_by_id("kw") elem = self.driver.find_element_by_id("su") el.send_keys("selenium") action = TouchActions(self.driver) action.tap(elem) action.perform() # 给定一个元素el,再给定一个坐标偏移量0代表横向不移动,2000代表纵向移动2000个像素位置 action.scroll_from_element(el, 0, 2000).perform()
def test_touchaction(self): self.driver.get("http://www.baidu.com") ele = self.driver.find_element(By.ID, "kw") ele.send_keys("ruby study") search_btn = self.driver.find_element(By.ID, "su") action = TouchActions(self.driver) action.tap(search_btn) sleep(5) action.scroll_from_element(ele, 0, 10000) action.perform() sleep(5)
def test_touch_action(self): self.driver.get("https://www.baidu.com") self.driver.find_element(By.ID, "kw").send_keys("selenium测试") ele1 = self.driver.find_element(By.ID, "su") action = TouchActions(self.driver) action.tap(ele1) action.scroll(0, 10000) action.perform() sleep(2) ele2 = self.driver.find_element(By.LINK_TEXT, "下一页>").click() sleep(2)
def moveTo(self, xPos, yPos, touchActions=None, delayPerform=False): action = None if touchActions is None: action = TouchActions(self.driver) else: action = touchActions action.move(xPos, yPos) if delayPerform == False: action.perform() return action return None
def touchDown(self, xPos, yPos, touchActions=None, delayPerform=False): action = None if touchActions is None: action = TouchActions(self.driver) else: action = touchActions action.tap_and_hold(xPos, yPos) if delayPerform == False: action.perform() return action return None
def test_touchaction(self, action=None): self.driver.get('https://www.baidu.com/') ele = self.driver.find_element_by_id("kw") ele_search = self.driver.find_element_by_id("su") ele.send_keys("selenium测试") action = TouchActions(self.driver) action.tap(ele_search) action.perform() #方法一 action.scroll_from_element(ele, 0, 1000).perform()
def test_touch(self): self.driver.get("https://www.baidu.com/") ele = self.driver.find_element_by_id("kw") ele_search = self.driver.find_element_by_id("su") ele.send_keys("bilibili") action = TouchActions(self.driver) action.tap(ele_search) action.perform() action.scroll_from_element(ele, 0, 10000).perform()
def test_touchaction(self): self.driver.get("https://www.baidu.com") el = self.driver.find_element(By.ID, "kw") el_search = self.driver.find_element(By.ID, "su") el.send_keys("测试") action = TouchActions(self.driver) action.tap(el_search) action.perform() action.scroll_from_element(el, 0, 10000).perform()
def test_touchaction(self): ele = self.driver.find_element(By.ID, "kw") ele_search = self.driver.find_element(By.ID, "su") ele.click() ele.send_keys("selenium测试") action = TouchActions(self.driver) action.tap(ele_search) action.perform() action.scroll_from_element(ele_search, 2, 10000).perform() sleep(3)
def longPressOnView(self, view, touchActions=None, delayPerform=False): if view is not None: action = None if touchActions is None: action = TouchActions(self.driver) else: action = touchActions action.long_press(view) if delayPerform == False: action.perform() return action return None
def test_touch(self): self.driver.get('http://www.baidu.com') el = self.driver.find_element(By.XPATH, ('//*[@id="kw"]')) el_search = self.driver.find_element(By.XPATH, ('//*[@id="su"]')) el.send_keys('我是你爸爸') action = TouchActions(self.driver) action.tap(el_search) action.perform() action.scroll(0, 10000).perform() eltext = self.driver.find_element_by_xpath( '//*[@id="page"]/a[8]/span[2]') action.tap(eltext).perform()
def test_touch_action(self): self.driver.get("https://www.baidu.com") element1 = self.driver.find_element_by_id("kw") element2 = self.driver.find_element_by_id("su") element1.send_keys("selenium测试") action = TouchActions(self.driver) action.tap(element2) action.perform() action.scroll_from_element(element1, 0, 10000).perform() sleep(5)
def test_touchaction(self): self.driver.get("https://www.baidu.com") element = self.driver.find_element_by_id("kw").send_keys("Selenium测试") element_button = self.driver.find_element_by_id("su") action = TouchActions(self.driver) action.tap(element_button) action.perform() sleep(5) action.scroll_from_element(element_button,0,10000).perform() self.driver.quit()
def test_touch(self): self.driver.get("https://www.baidu.com/") el = self.driver.find_element_by_id("kw") el_search = self.driver.find_element_by_id("su") el.send_keys("selenium测试") action = TouchActions(self.driver) # 点击搜索 action.tap(el_search) action.perform() # 滑动到最下边 action.scroll_from_element(el, 0, 1000).perform()