def test_touch_action(self): self.driver.get("https://baidu.com/") self.driver.find_element(By.ID, "kw").send_keys("霍格沃兹测试学校") action = TouchActions(self.driver) action.tap(self.driver.find_element(By.ID, "su")).perform() action.scroll_from_element(self.driver.find_element(By.ID, "su"), 0, 10000).perform()
class TestTouchAction(): def setup(self): option = webdriver.ChromeOptions() option.add_experimental_option('w3c', False) # 将w3c格式屏蔽掉 self.driver = webdriver.Chrome(options=option) self.action = TouchActions(self.driver) self.driver.maximize_window() self.driver.implicitly_wait(5) def teardown(self): self.driver.quit() def test_touchaction_scrollbotton(self): """ 打开Chrome 打开URL:http://www.baidu.com 向搜索框输入“selenium测试” 通过TouchAction点击搜索框 滑动到底部,点击下一页 关闭Chrome :return: """ self.driver.get('http://www.baidu.com') ele_input = self.driver.find_element_by_id('kw') ele_search = self.driver.find_element_by_id('su') ele_input.send_keys("selenium测试") self.action.tap(ele_search) # 触摸搜索按钮 self.action.scroll_from_element(ele_input, 0, 10000).perform() # 滚动页面,添加坐标偏移量
def test_touchaction_scrollbottom(self): self.driver.get("https://www.baidu.com/") el = self.driver.find_element(By.ID, "kw") el.send_keys("selenium测试") el1 = self.driver.find_element(By.ID, "su") action = TouchActions(self.driver) action.tap(el1) action.scroll_from_element(el, 0, 10000).perform()
def testScroll(self): self.driver.get("https://www.baidu.com") ele = self.driver.find_element(By.XPATH, "//*[@id='kw']") ele_search = self.driver.find_element(By.XPATH, "//*[@id='su']") ele.send_keys("selenium test") action = TouchActions(self.driver) action.tap(ele_search).perform() action.scroll_from_element(ele, 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_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_scroll_to_bottom(self): self.driver.get("https://www.baidu.com/") input_box = self.driver.find_element_by_id("kw") search_button = self.driver.find_element_by_id("su") input_box.send_keys("selenium测试") action = TouchActions(self.driver) action.tap(search_button) # 点击操作 action.scroll_from_element(input_box, 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_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 test_touchaction(self): self.driver.get("http://www.baidu.com") ele_input = self.driver.find_element(By.ID, "kw") ele_input.send_keys("selenium测试") ele_search = self.driver.find_element(By.ID, "su") action = TouchActions(self.driver) action.tap(ele_search).perform() action.scroll_from_element(ele_input, 0, 10000).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_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_touchAction_scollbottom(self): self.driver.get("https://www.baidu.com/") clc=self.driver.find_element_by_id("kw") clc.send_keys("selenium测试") clc2=self.driver.find_element_by_id("su") action= TouchActions(self.driver) action.tap(clc2).perform() action.scroll_from_element(clc2,0,10000).perform() time.sleep(5)
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_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(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_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_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_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_touch_actions(self): self.driver.get("http://www.baidu.com") e1 = self.driver.find_element_by_id('kw') el_search = self.driver.find_element_by_id('su') e1.send_keys("杨洋") action = TouchActions(self.driver) action.tap(el_search).perform() action.scroll_from_element(e1, 0, 10000).perform() time.sleep(3)
def test_case(self): self.driver.get("https://www.baidu.com/") self.driver.find_element_by_id("kw").send_keys("selenium测试") action_search = TouchActions(self.driver) action_search.tap(self.driver.find_element_by_id("su")).perform() el = self.driver.find_element_by_id("su") action = TouchActions(self.driver) # 向上滑动10000个像素 action.scroll_from_element(el, 0, 10000).perform() self.driver.find_element_by_xpath("//*[@id='page']/div/a[10]").click() sleep(3)
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_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_touch_scroll(self): self.driver.get('http://www.baidu.com') self.driver.find_element_by_xpath('//*[@id="kw"]').send_keys( 'selenium') sleep(5) ele = self.driver.find_element_by_xpath('//*[@id="su"]') action = TouchActions(self.driver) sleep(3) action.tap(ele).perform() sleep(3) action.scroll_from_element(ele, 0, 10000).perform()
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 test_scroll_bottom(self): self.driver.get("http://www.baidu.com") ele_input = self.driver.find_element_by_id('kw') ele_input.send_keys('selenium测试') # 输入框中输入内容 ele_search = self.driver.find_element_by_id('su') action = TouchActions(self.driver) action.tap(ele_search).perform() # 点击百度一下进行搜索 action.scroll_from_element(ele_input, 0, 10000).perform() # 完成页面滑动 sleep(2) self.driver.find_element_by_link_text("下一页 >").click() # 滑动到最下面点击下一页 sleep(1)