1、封装web基础操作类,其中包括获取元素、鼠标点击、键盘输入以及获取元素属性等方法
其中h5分页与pc页面分页的操作有差异,h5可能没有滚动条,是下拉页面来实现分页数据加载
try: js = "var a = document.body.scrollHeight;return a;" status = True height = self.driver.execute_script(js) print(height) self.driver.execute_script('window.scrollTo(0, 10000)') while status: new_height = self.driver.execute_script(js) print(new_height) # 每执行一次滚动条拖到最后,就进行一次参数校验,并且刷新页面高度 if new_height > height: self.driver.execute_script('window.scrollTo(0, document.body.scrollHeight)') height = new_height else: # 当页面高度不再增加的时候,我们就认为已经是页面最底部,结束条件判断 time.sleep(1) self.driver.execute_script('window.scrollTo(0, 0)') #log