scrolltop

Web自动化测试:滑动条移动

社会主义新天地 提交于 2019-12-06 02:40:23
生活中很多网站都是异步加载的,只有当你快要移动到那个位置,它才会开始加载,这样可以加快加载速度,让用户获得很好的体验。但是也给我们Web自动化带来了一定的困难,直接使用元素来定位后面的元素,因为还没有加载,所以会报错。怎么解决呢,就是移动滑动条,让它快速到达网页底部。 下面是我弄得一个在淘宝网页滑动下拉框的代码。 from selenium import webdriver from time import sleep wd = webdriver.Chrome() wd.get('https://www.taobao.com/') sd = 0 for i in range(1,50): sd += 100 js = "var q=document.documentElement.scrollTop=%s"%(sd) wd.execute_script(js) sleep(0.5) 大家可以看到滑动条是慢慢的往下移动,如果大家觉得这个速度太慢了,我们可以暴力点。 from selenium import webdriver from time import sleep wd = webdriver.Chrome(r'E:\webdrivers\chromedriver.exe') wd.get('https://www.taobao.com/') js = "var q

Scroll RecyclerView Scroll to position always on top

拥有回忆 提交于 2019-12-06 01:43:21
问题 I'm using linear layout manager and RecyclerView with a LinearLayout Manager to populate some list of items. When I'm displaying the recyclerview for the first time and I use: linearLayoutManager.scrollToPosition(desiredindex); it scrolls to the top exactly where I want. Now here is the tricky part - When I'm scrolling to top of recyclerview (i.e. new items indices will be lower than the desiredindex ) and I call: linearLayoutManager.scrollToPosition(desiredindex); It still works fine, but

Jquery .scrollTop() not working

六月ゝ 毕业季﹏ 提交于 2019-12-06 00:29:53
The title explains my problem. So here's my code: $("#my-div ul").scrollTop($("#my-div ul")[0].scrollHeight); #my-div get filled using AJAX. So in my ajax request, I've got a success callback which performs the above code: $.ajax({ url: 'getLog.php', data: {'logFile': 'log.php'}, // echo "<ul> A BUNCH OF <li>s here </ul>" success: function(data){ $("#my-div").html(data); // console.log($("#my-div ul")[0].scrollHeight); // Debugging Purposes $("#my-div ul").scrollTop($("#my-div ul")[0].scrollHeight); } }); I went ahead and console logged $("#my-div ul")[0].scrollHeight (As you can see in the

Get vertical position of scrollbar for a webpage on pageload when the url contains an anchor

好久不见. 提交于 2019-12-05 21:46:51
I am using jQuery's scrollTop() method to get the vertical position of the scroll bar on pageload. I need to get this value after the anchor in the url is executed (ex url: www.domainname.com#foo). I can use the following code and it works in Firefox and IE: ex url: www.domainname.com#foo $(document).ready(function() { if ($(this).scrollTop() > 0) { // then a conditional statement based on the scrollTop() value if ($(this).scrollTop() > $("#sidenav").height()) { ... But in Safari and Chrome document.ready() seems to execute before the anchor so scrollTop() returns 0 on page load in this

IE6的JS下fixed的常见解决办法

。_饼干妹妹 提交于 2019-12-05 17:38:03
- IE7已经支持position:fixed了,而我们的IE6呢?还继续使用js事件?消耗资源,破坏结构,画面闪耀。 第一种方法:纯CSS 目前网上有的比较多的是这种解决方案(纯CSS): 代码如下: html{overflow:hidden;} body{height:100%;overflow:auto;} #rightform form{position:absolute;right:30px;top50px;} 这个方法有一个bug未解决:在IE6下会把所有position:absolute都变成“浮动”的元素;还有使用js方法滚动滚动条时会出现对象闪烁,如下方法结合了CSS和js的办法,解决了以上的问题。 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>IE6 fixed</title> <style type=

JavaScript操作DOM对象

妖精的绣舞 提交于 2019-12-05 13:32:56
JavaScript操作DOM对象 DOM:document object model(文档对象模型) 访问节点 使用getElement系列方法访问指定节点: getElementById() getElementsByName() getElementsByTagName() 根据层次关系访问节点 节点属性 属性名称 描述 parentNode 返回节点的父节点 childNodes 返回子节点集合,childNodes[i] firstChild 返回节点的第一个子节点,最普遍的用法是访问该元素的文本节点 lastChild 返回节点的最后一个子节点 nextSibling 下一个节点 previousSibling 上一个节点 element属性 属性名称 描述 firstElementChild 返回节点的第一个子节点,最普遍的用法是访问该元素的文本节点 lastElementChild 返回节点的最后一个子节点 nextElementSibling 下一个节点 previousElementSibling 上一个节点 节点信息 nodeName:节点名称 nodeValue:节点值 nodeType:节点类型 节点类型 node type值 元素element 1 属性attr 2 文本text 3 注释comments 8 文档document 9 操作节点 1.

Cross Browser issue with jQuery offset()top returning different values

被刻印的时光 ゝ 提交于 2019-12-05 12:39:31
Essentially, what I'm trying to do, is apply a CSS class to an element in context to the scroll position of the document. Specifically, allowing my sidebar navigation to scroll to 20px below the top of the view port along with the rest of the content, at which point the element becomes of fixed position, thanks to the css class added, until the document is subsequently scrolled back up above that point, when the class is removed and the element again scrolls with the rest of the page content. I need the solution to be as light weight as possible and do not wish to use any library other than

超详细Vue实现导航栏绑定内容锚点+滚动动画+vue-router(hash模式可用)

这一生的挚爱 提交于 2019-12-05 06:56:14
超详细Vue实现导航栏绑定内容锚点+滚动动画+vue-router(hash模式可用) 转载自: https://www.jianshu.com/p/2ad8c8b5bf75 亲测有效~ <template> <div> <!-- 内容区域 --> <div class="content"> <div> content-0 </div> <div> content-1 </div> <div> content-2 </div> <div> content-3 </div> <div> content-4 </div> </div> <!-- 导航区域 --> <ul class="navs"> <li :class="{active: active===0}" @click="scrollTo(0)"> content-0 </li> <li :class="{active: active===1}" @click="scrollTo(1)"> content-1 </li> <li :class="{active: active===2}" @click="scrollTo(2)"> content-2 </li> <li :class="{active: active===3}" @click="scrollTo(3)"> content-3 </li> <li :class=

h5滚动页面固定导航

蹲街弑〆低调 提交于 2019-12-05 04:47:49
1、需要效果 2、实现方法 (1)原生js实现 document.addEventListener('scroll', function (event) { var scrollDamo = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; if (scrollDamo >= 350) { // 触发的位置 document.getElementsByClassName('cont-info-kc')[0].style.cssText = 'position:fixed;'; } else { document.getElementsByClassName('cont-info-kc')[0].style.cssText = 'position:static;'; } }); html <div class="cont-info-kc"></div> (2) vue实现 <div style="height:16px;background:#F4F4F4" id='testNavBar'></div> <div id="cont-info-kc" :class='{ fixedNavbar: isfixTab }'> <ul> <li :class="period

scroll及相关属性

夙愿已清 提交于 2019-12-05 04:21:34
1. 获取滚动条的高度 Safari中使用的是 window.pageYOffset IE中是 document.body.scrollTop 以及 document.documentElement.scrollTop; 所以兼容性的写法是: 1 var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; 2. 将某个元素跳转到浏览器视口的最上方 括号内的参数为Boolean型参数或Object型参数 1 element.scrollIntoView(); Boolean型参数 true :元素的顶端将和其所在滚动区的可视区域的顶端对齐 ;(默认) false :元素的底端将和其所在滚动区的可视区域的底端对齐 element.scrollIntoView(alignToTop); 1 element.scrollIntoView(scrollIntoViewOptions)   Object型参数 {   behavior: "auto"(默认) | "instant" | "smooth"(缓动), block: "start" | "end"   } ; 来源: https://www.cnblogs.com/cnlisiyiii-stu