Skip to content

Commit b66f0bc

Browse files
committed
Enhanced both installation documentation, INSTALL.rst and developer documentation, BUILD.rst.
Under the installation doc, added alternative "Installing from PyPI" section titles with addition section titles for various OSes. Added section on verifying proper instalation and troubleshoutting section. Also added stubs for documenting/educating end users on the various different "flavors" of python and the various packaging tools, including pip, easy_install, and buildout that the Python community uses. Under the developer documentation, added section stubs for virtualenv, debugging Selenium2Library, and profiling. Added information on how to write tests for selenium in order to discern whre issues lie, whether within Selenium2Library or elsewhere.
1 parent 7989cfa commit b66f0bc

File tree

2 files changed

+153
-4
lines changed

2 files changed

+153
-4
lines changed

BUILD.rst

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ test/
2424
Unit and acceptance tests for Selenium2Library
2525

2626

27+
Using virtualenv
28+
----------------
29+
Background information about what virtualenv is, why one should be using virtualenv and how to use it
30+
2731
Unit and Acceptance Tests
2832
-------------------------
2933

@@ -63,6 +67,103 @@ To run just the unit tests, run::
6367

6468
python test/run_unit_tests.py
6569

70+
Debugging Selenium2Library
71+
--------------------------
72+
73+
Testing Third-Party Packages
74+
----------------------------
75+
76+
Sometimes in the process of developing and testing Selenium2Library
77+
one needs to determine whether or not an issue is within Selenium2Library
78+
or if it lies within a third-party package like Selenium or Robot Framework.
79+
Here are some hints for writing quick, short unit tests against Selenium
80+
and Robot Framework.
81+
82+
Testing Selenium
83+
~~~~~~~~~~~~~~~~
84+
First create a test directory and create an isolated Python environment
85+
using virtualenv::
86+
87+
~$ mkdir se-bug
88+
~$ cd se-bug
89+
~/se-bug$ virtualenv -p /usr/bin/python2.6 --no-site-packages clean-python26-env
90+
91+
Activate the virtual environment::
92+
93+
~/se-bug$ source clean-python26-env/bin/activate
94+
95+
Install the version of Selenium for which you wish to test. In the following
96+
case we are going to check Selenium version 2.25.0.
97+
98+
(clean-python26-env) ~/se-bug$ easy_install selenium==2.25.0
99+
100+
Create a test file, in this case ~/se-bug/testExeJS.py::
101+
102+
import unittest
103+
from selenium import webdriver
104+
105+
class ExecuteJavascriptTestCase(unittest.TestCase):
106+
107+
def setUp(self):
108+
self.driver = webdriver.Firefox()
109+
110+
def test_exe_javascript(self):
111+
driver = self.driver
112+
driver.get("http://www.google.com")
113+
url = driver.execute_script("return [ document.location ];")
114+
print('Finished')
115+
self.assertEqual(url[0]['href'], u"http://www.google.com/")
116+
117+
def tearDown(self):
118+
self.driver.close()
119+
120+
if __name__ == "__main__":
121+
unittest.main()
122+
123+
Breaking down this example test case we see in the setUp and tearDown
124+
methods we initiate and close the Firefox webdriver, respectively.
125+
In the one test, text_exe_javascript, we perform steps to verify or
126+
disprove the issue we are experiencing is with Selenium only. (In
127+
`this case`_ the browser was hanging after the execute_script call and
128+
not returning; thus I printed 'Finished' to help show where the test
129+
progressed to.)
130+
131+
An important part of the above test case, and all unit tests, is the
132+
line "self.assertEqual(...". This is one example of the method's
133+
available to check for errors or failures. For example, you can check
134+
for trueness or falseness of a stament by using assertTrue() and
135+
assertFalse(). Or you can for inclusiveness and exclussiveness by using
136+
assertIn() and assertNotIn(), respectively. For more information about
137+
unittest see `Python's unittest documentation`_. The last two lines
138+
allow this test to be run from the command line.
139+
140+
To run the unittest type::
141+
142+
(clean-python26-env) ~/se-bug$ python testExeJS.py
143+
144+
In this example I removed the troubled selenium version and reinstalled a
145+
previous version, re-running the test case to verfiy selenium was the
146+
problem and not Selenium2Library::
147+
148+
(clean-python26-env) ~/se-bug$ rm -Rf clean-python26-env/lib/python2.6/site-packages/selenium-2.25.0-py2.6.egg
149+
(clean-python26-env) ~/se-bug$ easy_install selenium==2.24.0
150+
(clean-python26-env) ~/se-bug$ python testExeJS.py
151+
Finished
152+
.
153+
----------------------------------------------------------------------
154+
Ran 1 test in 6.198s
155+
156+
OK
157+
(clean-python26-env) ~/se-bug$
158+
159+
If you discover an issue with Selenium it is helpful to `report it`_ to
160+
the Selenium developers.
161+
162+
163+
Profiling
164+
---------
165+
information on how to profile Selenium2Library code
166+
66167

67168
Pushing Code to GitHub
68169
----------------------
@@ -187,3 +288,6 @@ are parsed by the reStructuredText parser. To build them, run::
187288
.. _downloads section on GitHub: https://github.com/rtomac/robotframework-selenium2library/downloads
188289
.. _PyPI: http://pypi.python.org
189290
.. _.pypirc file: http://docs.python.org/distutils/packageindex.html#the-pypirc-file
291+
.. _this case: http://code.google.com/p/selenium/issues/detail?id=4375
292+
.. _report it: http://code.google.com/p/selenium/issues/list
293+
.. _Python's unittest documentation: http://docs.python.org/library/unittest.html

INSTALL.rst

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ are the most restrictive, and as of now require Python 2.6 or Python 2.7.
1111

1212
Selenium2Library depends on a few other Python libraries, including
1313
of course Robot Framework and Selenium. All dependencies are declared
14-
in setup.py. If you use pip or easy_install to install this library, the
15-
dependencies will be installed for you (this is recommended).
16-
17-
14+
in setup.py.
15+
16+
Installing on Windows
17+
---------------------
18+
or (because easy_install under Windows doesn't install dependencies)
19+
Installing using pip (recommended)
20+
--------------------
21+
but not (because pip does not necessarily install from pypi)
1822
Installing from PyPI (recommended)
1923
----------------------------------
2024

@@ -27,6 +31,11 @@ Or alternately, if you only have `easy_install`_,::
2731

2832
easy_install robotframework-selenium2library
2933

34+
Installing on Linux
35+
-------------------
36+
Installing on Mac OSX
37+
---------------------
38+
if we use `Installing on Windows`_ then we need sections for other OSes
3039

3140
Installing from source
3241
----------------------
@@ -57,6 +66,42 @@ double-click the installer and follow the instructions.
5766
Selenium2Library can be uninstalled using the Programs and Features utility from
5867
Control Panel (Add/Remove Programs on older versions of Windows).
5968

69+
Verifying Installation
70+
----------------------
71+
72+
Once you have installed Selenium2Library it is a good idea to verify the installation. To verify installation start python::
73+
74+
C:\> python
75+
76+
and then at the Python prompt type::
77+
78+
>> import Selenium2Library
79+
>>
80+
81+
If the python command line interpretor returns with another prompt ('>>' as shown above) then your installation was successful.
82+
83+
Troubleshooting Installation
84+
----------------------------
85+
86+
The most common issue with installing Selenium2Library is missing dependencies. An error like::
87+
88+
ImportError: No module named robot.variables
89+
90+
indicates that you are missing the Robot Framework package. To correct this problem try typing at the prompt::
91+
92+
easy_install robotframework
93+
94+
Similarly if you receive "No module named ..." error message then you have another missing dependency. To correct, use easy_install to install the missing package.
95+
96+
Different Flavors of Python
97+
---------------------------
98+
CPython, PyPy, Iron Python, ActivePython, 32 bit, 64 bit. Not all flavors of Python are the same. Explain the differences and some expected roadblocks with various versions.
99+
100+
Python Packaging Tools
101+
----------------------
102+
The in's and out's of easy_setup, pip, etc. Explain how to upgrade a package using pip.
103+
104+
60105

61106
.. _Selenium Python Bindings: http://code.google.com/p/selenium/wiki/PythonBindings
62107
.. _PyPI: http://code.google.com/p/selenium/wiki/PythonBindings

0 commit comments

Comments
 (0)