Skip to content

Commit 1a061a3

Browse files
committed
Working with Selenium and PhantomJS
1 parent 809ea9b commit 1a061a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+9218
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
output
22
*~
33
*.pyc
4+
*.log

phantomjs_linux_64

36.6 MB
Binary file not shown.

selenium/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2008-2013 Software Freedom Conservancy
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from selenium import selenium
16+
17+
18+
__version__ = "2.42.1"

selenium/common/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2008-2010 WebDriver committers
2+
# Copyright 2008-2010 Google Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
from . import exceptions

selenium/common/exceptions.py

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
# Copyright 2008-2009 WebDriver committers
2+
# Copyright 2008-2009 Google Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
"""
17+
Exceptions that may happen in all the webdriver code.
18+
"""
19+
20+
class WebDriverException(Exception):
21+
"""
22+
Base webdriver exception.
23+
"""
24+
25+
def __init__(self, msg=None, screen=None, stacktrace=None):
26+
self.msg = msg
27+
self.screen = screen
28+
self.stacktrace = stacktrace
29+
30+
def __str__(self):
31+
exception_msg = "Message: %s " % repr(self.msg)
32+
if self.screen is not None:
33+
exception_msg = "%s; Screenshot: available via screen " \
34+
% exception_msg
35+
if self.stacktrace is not None:
36+
exception_msg = "%s; Stacktrace: %s " \
37+
% (exception_msg, str("\n" + "\n".join(self.stacktrace)))
38+
return exception_msg
39+
40+
class ErrorInResponseException(WebDriverException):
41+
"""
42+
Thrown when an error has occurred on the server side.
43+
44+
This may happen when communicating with the firefox extension
45+
or the remote driver server.
46+
"""
47+
def __init__(self, response, msg):
48+
WebDriverException.__init__(self, msg)
49+
self.response = response
50+
51+
class InvalidSwitchToTargetException(WebDriverException):
52+
"""
53+
Thrown when frame or window target to be switched doesn't exist.
54+
"""
55+
pass
56+
57+
class NoSuchFrameException(InvalidSwitchToTargetException):
58+
"""
59+
Thrown when frame target to be switched doesn't exist.
60+
"""
61+
pass
62+
63+
class NoSuchWindowException(InvalidSwitchToTargetException):
64+
"""
65+
Thrown when window target to be switched doesn't exist.
66+
67+
To find the current set of active window handles, you can get a list
68+
of the active window handles in the following way::
69+
70+
print driver.window_handles
71+
72+
"""
73+
pass
74+
75+
class NoSuchElementException(WebDriverException):
76+
"""
77+
Thrown when element could not be found.
78+
79+
If you encounter this exception, you may want to check the following:
80+
* Check your selector used in your find_by...
81+
* Element may not yet be on the screen at the time of the find operation,
82+
(webpage is still loading) see selenium.webdriver.support.wait.WebDriverWait()
83+
for how to write a wait wrapper to wait for an element to appear.
84+
"""
85+
pass
86+
87+
class NoSuchAttributeException(WebDriverException):
88+
"""
89+
Thrown when the attribute of element could not be found.
90+
91+
You may want to check if the attribute exists in the particular browser you are
92+
testing against. Some browsers may have different property names for the same
93+
property. (IE8's .innerText vs. Firefox .textContent)
94+
"""
95+
pass
96+
97+
class StaleElementReferenceException(WebDriverException):
98+
"""
99+
Thrown when a reference to an element is now "stale".
100+
101+
Stale means the element no longer appears on the DOM of the page.
102+
103+
104+
Possible causes of StaleElementReferenceException include, but not limited to:
105+
* You are no longer on the same page, or the page may have refreshed since the element
106+
was located.
107+
* The element may have been removed and re-added to the screen, since it was located.
108+
Such as an element being relocated.
109+
This can happen typically with a javascript framework when values are updated and the
110+
node is rebuilt.
111+
* Element may have been inside an iframe or another context which was refreshed.
112+
"""
113+
pass
114+
115+
class InvalidElementStateException(WebDriverException):
116+
"""
117+
"""
118+
pass
119+
120+
class UnexpectedAlertPresentException(WebDriverException):
121+
"""
122+
Thrown when an unexpected alert is appeared.
123+
124+
Usually raised when when an expected modal is blocking webdriver form executing any
125+
more commands.
126+
"""
127+
pass
128+
129+
class NoAlertPresentException(WebDriverException):
130+
"""
131+
Thrown when switching to no presented alert.
132+
133+
This can be caused by calling an operation on the Alert() class when an alert is
134+
not yet on the screen.
135+
"""
136+
pass
137+
138+
class ElementNotVisibleException(InvalidElementStateException):
139+
"""
140+
Thrown when an element is present on the DOM, but
141+
it is not visible, and so is not able to be interacted with.
142+
143+
Most commonly encountered when trying to click or read text
144+
of an element that is hidden from view.
145+
"""
146+
pass
147+
148+
class ElementNotSelectableException(InvalidElementStateException):
149+
"""
150+
Thrown when trying to select an unselectable element.
151+
152+
For example, selecting a 'script' element.
153+
"""
154+
pass
155+
156+
class InvalidCookieDomainException(WebDriverException):
157+
"""
158+
Thrown when attempting to add a cookie under a different domain
159+
than the current URL.
160+
"""
161+
pass
162+
163+
class UnableToSetCookieException(WebDriverException):
164+
"""
165+
Thrown when a driver fails to set a cookie.
166+
"""
167+
pass
168+
169+
class RemoteDriverServerException(WebDriverException):
170+
"""
171+
"""
172+
pass
173+
174+
class TimeoutException(WebDriverException):
175+
"""
176+
Thrown when a command does not complete in enough time.
177+
"""
178+
pass
179+
180+
class MoveTargetOutOfBoundsException(WebDriverException):
181+
"""
182+
Thrown when the target provided to the `ActionsChains` move()
183+
method is invalid, i.e. out of document.
184+
"""
185+
pass
186+
187+
class UnexpectedTagNameException(WebDriverException):
188+
"""
189+
Thrown when a support class did not get an expected web element.
190+
"""
191+
pass
192+
193+
class InvalidSelectorException(NoSuchElementException):
194+
"""
195+
Thrown when the selector which is used to find an element does not return
196+
a WebElement. Currently this only happens when the selector is an xpath
197+
expression and it is either syntactically invalid (i.e. it is not a
198+
xpath expression) or the expression does not select WebElements
199+
(e.g. "count(//input)").
200+
"""
201+
pass
202+
203+
class ImeNotAvailableException(WebDriverException):
204+
"""
205+
Thrown when IME support is not available. This exception is thrown for every IME-related
206+
method call if IME support is not available on the machine.
207+
"""
208+
pass
209+
210+
class ImeActivationFailedException(WebDriverException):
211+
"""
212+
Thrown when activating an IME engine has failed.
213+
"""
214+
pass

0 commit comments

Comments
 (0)