@@ -26,32 +26,31 @@ Does Selenium 2 support XPath 2.0 ?
26
26
27
27
Ref: http://seleniumhq.org/docs/03_webdriver.html#how-xpath-works-in-webdriver
28
28
29
- Selenium delegates XPath queries down to the browser's own XPath
30
- engine, so Selenium support XPath supports whatever the browser
31
- supports. In browsers which don't have native XPath engines (IE
32
- 6,7,8), Selenium supports XPath 1.0 only.
29
+ Selenium delegates XPath queries down to the browser's own XPath engine, so
30
+ Selenium support XPath supports whatever the browser supports. In browsers
31
+ which don't have native XPath engines (IE 6,7,8), Selenium supports XPath 1.0
32
+ only.
33
33
34
34
35
35
How to scroll down to the bottom of a page ?
36
36
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37
37
38
38
Ref: http://blog.varunin.com/2011/08/scrolling-on-pages-using-selenium.html
39
39
40
- You can use the `execute_script ` method to execute javascript on the
41
- loaded page. So, you can call the JavaScript API to scroll to the
42
- bottom or any other position of a page.
40
+ You can use the `execute_script ` method to execute javascript on the loaded
41
+ page. So, you can call the JavaScript API to scroll to the bottom or any other
42
+ position of a page.
43
43
44
44
Here is an example to scroll to the bottom of a page::
45
45
46
46
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
47
47
48
- The `window <http://www.w3schools.com/jsref/obj_window.asp >`_ object
49
- in DOM has a `scrollTo
50
- <http://www.w3schools.com/jsref/met_win_scrollto.asp> `_ method to
48
+ The `window <http://www.w3schools.com/jsref/obj_window.asp >`_ object in DOM has
49
+ a `scrollTo <http://www.w3schools.com/jsref/met_win_scrollto.asp >`_ method to
51
50
scroll to any position of an opened window. The `scrollHeight
52
- <http://www.w3schools.com/jsref/dom_obj_all.asp> `_ is a common
53
- property for all elements. The `document.body.scrollHeight ` will give
54
- the height of the entire body of the page.
51
+ <http://www.w3schools.com/jsref/dom_obj_all.asp> `_ is a common property for all
52
+ elements. The `document.body.scrollHeight ` will give the height of the entire
53
+ body of the page.
55
54
56
55
How to auto save files using custom Firefox profile ?
57
56
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -74,8 +73,8 @@ Another way to find content type is using the `requests
74
73
content_type = requests.head('http://www.python.org').headers['content-type']
75
74
print(content_type)
76
75
77
- Once the content type is identified, you can use it to set the firefox
78
- profile preference: ``browser.helperApps.neverAsk.saveToDisk ``
76
+ Once the content type is identified, you can use it to set the firefox profile
77
+ preference: ``browser.helperApps.neverAsk.saveToDisk ``
79
78
80
79
Here is an example::
81
80
@@ -94,24 +93,24 @@ Here is an example::
94
93
browser.get("http://pypi.python.org/pypi/selenium")
95
94
browser.find_element_by_partial_link_text("selenium-2").click()
96
95
97
- In the above example, ``application/octet-stream `` is used as the
98
- content type.
96
+ In the above example, ``application/octet-stream `` is used as the content type.
99
97
100
- The ``browser.download.dir `` option specify the directory where you
101
- want to download the files.
98
+ The ``browser.download.dir `` option specify the directory where you want to
99
+ download the files.
102
100
103
101
How to upload files into file inputs ?
104
102
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105
103
106
- Select the ``<input type="file"> `` element and call the ``send_keys() `` method passing
107
- the file path, either the path relative to the test script, or an absolute path.
108
- Keep in mind the differences in path names between Windows and Unix systems.
104
+ Select the ``<input type="file"> `` element and call the ``send_keys() `` method
105
+ passing the file path, either the path relative to the test script, or an
106
+ absolute path. Keep in mind the differences in path names between Windows and
107
+ Unix systems.
109
108
110
109
How to use firebug with Firefox ?
111
110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112
111
113
- First download the Firebug XPI file, later you call the
114
- `` add_extension `` method available for the firefox profile::
112
+ First download the Firebug XPI file, later you call the `` add_extension `` method
113
+ available for the firefox profile::
115
114
116
115
from selenium import webdriver
117
116
0 commit comments