import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
PyDev console: starting.
C:\Python27\python.exe 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]

import subprocess
import time

import scrapy

from selenium import webdriver
from scrapy.spiders.crawl import CrawlSpider
loginUri = r'http://www.test1.com/'
driver = webdriver.Firefox()

driver.get(loginUri)
driver.find_element_by_name('input1').send_keys('mycnblogs_2015')
driver.find_element_by_name('input2').send_keys('075528560160...cnblogs')

driver.find_element_by_name('signin').click()
alllinks = driver.find_elements_by_xpath(r'//a')
a = alllinks[0]
pr
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'pr' is not defined
print a
<selenium.webdriver.remote.webelement.WebElement (session="f57849aa-5174-4dea-93c1-030e4fbf21f8", element="{14bf9be1-05c9-440f-adc8-2be8ac5696aa}")>
dir(a)
['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_execute', '_id', '_parent', '_upload', '_w3c', 'clear', 'click', 'find_element', 'find_element_by_class_name', 'find_element_by_css_selector', 'find_element_by_id', 'find_element_by_link_text', 'find_element_by_name', 'find_element_by_partial_link_text', 'find_element_by_tag_name', 'find_element_by_xpath', 'find_elements', 'find_elements_by_class_name', 'find_elements_by_css_selector', 'find_elements_by_id', 'find_elements_by_link_text', 'find_elements_by_name', 'find_elements_by_partial_link_text', 'find_elements_by_tag_name', 'find_elements_by_xpath', 'get_attribute', 'id', 'is_displayed', 'is_enabled', 'is_selected', 'location', 'location_once_scrolled_into_view', 'parent', 'rect', 'screenshot', 'screenshot_as_base64', 'screenshot_as_png', 'send_keys', 'size', 'submit', 'tag_name', 'text', 'value_of_css_property']

a.get_attribute()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: get_attribute() takes exactly 2 arguments (1 given)
a.get_attributes
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'WebElement' object has no attribute 'get_attributes'
a.id
u'{14bf9be1-05c9-440f-adc8-2be8ac5696aa}'
a.is_displayed()
True
a.is_enabled()
True
a.is_selected
<bound method WebElement.is_selected of <selenium.webdriver.remote.webelement.WebElement (session="f57849aa-5174-4dea-93c1-030e4fbf21f8", element="{14bf9be1-05c9-440f-adc8-2be8ac5696aa}")>>
a.is_selected()
False
a.location
{'y': 29, 'x': 8}
location_once_scrolled_into_view
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'location_once_scrolled_into_view' is not defined
a.location_once_scrolled_into_view
{u'y': 29, u'x': 8}
a.parent
<selenium.webdriver.firefox.webdriver.WebDriver (session="f57849aa-5174-4dea-93c1-030e4fbf21f8")>
a.parent()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: 'WebDriver' object is not callable
a.parent
<selenium.webdriver.firefox.webdriver.WebDriver (session="f57849aa-5174-4dea-93c1-030e4fbf21f8")>
a.rect
{u'y': 29, u'x': 8, u'height': 21, u'width': 62}
a.screenshot('e:\\a.png')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 405, in screenshot
    png = self.screenshot_as_png
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 392, in screenshot_as_png
    return base64.b64decode(self.screenshot_as_base64.encode('ascii'))
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 382, in screenshot_as_base64
    return self._execute(Command.ELEMENT_SCREENSHOT)['value']
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 454, in _execute
    return self._parent.execute(command, params)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 102, in check_response
    value = json.loads(value_json)
  File "C:\Python27\lib\json\__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "C:\Python27\lib\json\decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
a.screenshot_as_png
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 392, in screenshot_as_png
    return base64.b64decode(self.screenshot_as_base64.encode('ascii'))
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 382, in screenshot_as_base64
    return self._execute(Command.ELEMENT_SCREENSHOT)['value']
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 454, in _execute
    return self._parent.execute(command, params)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 102, in check_response
    value = json.loads(value_json)
  File "C:\Python27\lib\json\__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "C:\Python27\lib\json\decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
a.screenshot_as_png('e:\\a.png')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 392, in screenshot_as_png
    return base64.b64decode(self.screenshot_as_base64.encode('ascii'))
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 382, in screenshot_as_base64
    return self._execute(Command.ELEMENT_SCREENSHOT)['value']
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 454, in _execute
    return self._parent.execute(command, params)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 102, in check_response
    value = json.loads(value_json)
  File "C:\Python27\lib\json\__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "C:\Python27\lib\json\decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
a.size()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: 'dict' object is not callable
a.size
{'width': 62, 'height': 21}
a.tag_name
u'a'
a.text
u'link to a'
a.value_of_css_property(property_name)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'property_name' is not defined
a.get_attribute('href')
u'http://www.test1.com/a.php'

webdriver函数的更多相关文章

  1. selenium python (一) 开发环境搭建

    1.工具下载: python工具共包括三个:python.setuptools.pip ²  python:http://python.org/getit/     python开发环境: ²  se ...

  2. selenium python 第一个脚本

    为什么选择python?我的回答很简单,简单易学,功能强大! 下面看看python和selenium 2的结合是什么样子吧 一.第一个selenium python脚本: #coding = utf- ...

  3. Selenium在Firefox中踩过的

    本文转至 http://www.51testing.com/html/11/n-3711311.html,作者对webdriver在Firefox中设置profile配置项挺熟的,是用Python实现 ...

  4. 使用CSS选择器进行元素定位

    在selenium webdriver中,支持使用CSS选择器来进行元素定位,事实在真的投入工作,大量编辑用例和元素定位的时候,使用css 和 xpath才是经常需要用到的. 之前有专门讲过使用xpa ...

  5. JUnit 5和Selenium基础(二)

    使用Selenium内置的PageFactory实现页面对象模式 在这一部分中,将通过Selenium的内置PageFactory支持类来介绍Page Object模式的实现.PageFactory提 ...

  6. Python+Selenium WebDriver API:浏览器及元素的常用函数及变量整理总结

    由于网页自动化要操作浏览器以及浏览器页面元素,这里笔者就将浏览器及页面元素常用的函数及变量整理总结一下,以供读者在编写网页自动化测试时查阅. from selenium import webdrive ...

  7. 在Selenium Webdriver中使用XPath Contains、Sibling函数定位

    前言 在一般情况下,我们通过简单的xpath即可定位到目标元素,但对于一些既没id又没name,而且其他属性都是动态的情况就很难通过简单的方式进行定位了. 在这种情况下,我们需要使用xpath1.0内 ...

  8. selenium2 webdriver 常用的python 函数

    新建实例driver = webdriver.Chrome() 1.通过标签属性Id查找元素 方法:find_element_by_id(element_id) 实例:driver.find_elem ...

  9. 查看webdriver针对浏览器的一些函数

    在用webdriver对浏览器进行操作时,很多操作并不是那么好找,后来在朋友的推荐下可以用下面的方法来寻找针对浏览器的一些操作,函数或属性等,这样方便我们可以查找一些方法去完成我们要的操作. 下面是查 ...

随机推荐

  1. 「暑期训练」「Brute Force」 Optimal Point on a Line (Educational Codeforces Round 16, B)

    题意 You are given n points on a line with their coordinates $x_i$. Find the point x so the sum of dis ...

  2. C++学习004-Go To 语句使用

    C++中,goto语句主要负责语句的跳转,可以用在循环中跳出循环 注意gotu语句是无条件跳转,用的时候一定要谨慎,一定要少 编写环境 Qt 5.7 for(int i = 0;i<100;i+ ...

  3. Android Spiner实现Key-Value

    原网址:http://www.eoeandroid.com/thread-29687-1-1.html?_dsign=02d5cd6a 学习到的方法,直接上代码了: 1.定义一个class publi ...

  4. json格式化显示样式js代码分享

    最近开发中需要在页面展示json.特整理了下代码,送给大家,希望能帮到有同样需求的朋友们. 代码: <html> <script src="http://cdn.bootc ...

  5. 数据结构(python语言)目录链接

    第一章 准备工作 课时0:0.数据结构(python语言) 基本概念 算法的代价及度量!!!

  6. LeetCode 2——两数相加

    1. 题目 2. 解答 循环遍历两个链表 若两个链表都非空,将两个链表结点的值和进位相加求出和以及新的进位 若其中一个链表为空,则将另一个链表结点的值和进位相加求出和以及新的进位 然后将每一位的和添加 ...

  7. Gated Recurrent Unit (GRU)

                                   Gated Recurrent Unit (GRU) Outline                             Backgr ...

  8. XML中的DTD语法

    DTD(Document Type Definition),全称为文档类型定义. 文件清单:book.xml <?xml version="1.0" ?> <!D ...

  9. java实现数据库连接的工具类

    第一种 (带事务) package com.china.util; import java.sql.Connection; import java.sql.DriverManager; import ...

  10. 【bzoj3379】[Usaco2004 Open]Turning in Homework 交作业 区间dp

    题目描述 数轴上有C个点,每个点有一个坐标和一个访问时间,必须在这个时间后到达这个点才算访问完成.可以在某个位置停留.每在数轴上走一个单位长度消耗一个单位的时间,问:访问所有点并最终到B花费的最小时间 ...