代码要多敲 注释要清晰

最后的两种方法,没有实现我想要的结果

有知道的朋友,给我留言吧

#执行js语句

from selenium import webdriver
import time #生成浏览器
driver = webdriver.PhantomJS()
#访问
driver.get('http://www.baidu.com') time.sleep(4)
#截屏并保存
driver.save_screenshot('baidu/index1.png') #1.通过js改变页面控件的属性 (边框属性,颜色,线的类型)
js = 'q = document.getElementById("kw");q.style.border = \"3px solid red\";'
#执行js操作
driver.execute_script(js)
#截屏并保存
driver.save_screenshot('baidu/index2.png') #2.通过js隐藏元素
img = driver.find_elements_by_xpath('//*[id="lg"]/img')
driver.execute_script('$(arguments[0]).fadeOut()',img)
time.sleep(4)
driver.save_screenshot('baidu/index3.png') #没有出来结果 #向下滚动到页面底部 我的js忘得差不多了啊 要多补补
js = '$(".scroll_top").click(function(){$(html.body).animate({scrollTop:"0px"},800)});'
driver.execute_script(js)
time.sleep(4)
driver.save_screenshot('baidu/index4.png')

selenium,webdriver 执行js语句 对象是百度的更多相关文章

  1. java selenium webdriver处理JS操作窗口滚动条

    未经作者允许,禁止转载!!! java selenium webdriver处理JS操作窗口滚动条 java selenium webdriver处理JS操作窗口滚动条 import org.open ...

  2. Python selenium webdriver设置js操作页面滚动条

    js2 = "window.scrollTo(0,0);" #括号中为坐标 当不知道需要的滚动的坐标大小时: weizhi2 = driver.find_element_by_id ...

  3. 转:selenium webdriver 执行javascript代码

    在用selenium webdriver 编写web页面的自动化测试代码时,可能需要执行一些javascript代码,selenium本身就支持执行js,我们在代码中import org.openqa ...

  4. selenium webdriver ——执行javascript代码

    在代码中import org.openqa.selenium.JavascriptExecutor;就可以使用executeScript.executeAsyncScript这两个方法了 execut ...

  5. python3之selenium.webdriver 库练习自动化谷歌浏览器打开百度自动百度关键字

    import os,time,threading from selenium import webdriver from selenium.webdriver.common.keys import K ...

  6. 如何用selenium webdriver 捕获js error

    ### 问题 捕捉页面上js error ### 解决办法 从Selenium webdriver log 中解析 # -*- coding:utf8 -*- import unittest from ...

  7. 使用Webdriver执行JS小结

    首先,我们使用如下方式初始化driver: WebDriver driver = new FirefoxDriver(); JavascriptExecutor jse = (JavascriptEx ...

  8. 使用Webdriver执行JS

    首先,我们使用如下方式初始化driver: WebDriver driver = new FirefoxDriver(); JavascriptExecutor jse = (JavascriptEx ...

  9. selenium webdriver执行远程 第三方js解决方案

    今天一个朋友问我问题 考虑了下直接上代码,这是伪代码不能执行,但是给出了思路 代码 url = 'http://www.qingmiaokeji.cn/test.js' res = urllib.re ...

随机推荐

  1. Codeforces 1082D (贪心)

    题面 传送门 分析 贪心 将度限制大于1的点连成一条链,然后将度限制等于1的点挂上去 形状如下图,其中(1,2,3)为度数限制>1的点 显然直径长度=(度数限制>1的节点个数)-1+min ...

  2. 天堂Lineage(單機版)從零開始架設教學 Installing Lineage 3.52 Server - On Windows

      1. [下載原始碼] Using RapidSVN 用checkout      http://l1j-tw-99nets.googlecode.com/svn/trunk/L1J-TW_3.50 ...

  3. UVALive 6270 Edge Case(找规律,大数相加)

    版权声明:本文为博主原创文章,未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/36905379 转载请注明出 ...

  4. 【学习总结】Python-3-字符串函数-strip()方法

    参考: 菜鸟教程-Python3-Python字符串-strip()方法 语法: str.strip([chars]); 参数: chars -- 移除字符串头尾指定的字符序列. 返回值: 返回移除字 ...

  5. Solr的学习使用之(二)schema.xml等配置文件的解析

    上一篇文章已经讲解了如何部署Solr,部署是部署完了,可是总觉得心里空空的,没底,里面有N多配置文件,比如schema.xml.solrConfig.xml.solr.xml and so on……都 ...

  6. C语言实现读取文件所有内容到字符串

    #include "stdio.h" #include "string" #include "stdlib.h" using namespa ...

  7. maven system path,加载本地jar

    当引用第三方包,且没有源代码时候,可以使用system path <dependency> <groupId>ctec</groupId> <artifact ...

  8. Cytoscape基础教程笔记

    昨天开始学用Cytoscape,其tutorial分为两个部分,基础的和高级 的.基础教程又分成了四课:Getting Started.Filters & Editor.Fetching Ex ...

  9. JavaWeb(三):JSP

    JSP是JavaServer Page的缩写,也就是服务端网页. 一.概述 1.1 为什么使用JSP 在很多动态网页中,绝大部分内容都是固定不变的,只有局部内容需要动态产生和改变.JSP是简化Serv ...

  10. 通俗理解BiLSTM-CRF命名实体识别模型中的CRF层

    虽然网上的文章对BiLSTM-CRF模型介绍的文章有很多,但是一般对CRF层的解读比较少. 于是决定,写一系列专门用来解读BiLSTM-CRF模型中的CRF层的文章. 我是用英文写的,发表在了gith ...