Skip to content

Commit 3c13653

Browse files
authored
Merge pull request #138 from seleniumbase/compatibility-with-selenium-2
Compatibility with selenium 2
2 parents 6f7d76b + c5855b5 commit 3c13653

File tree

6 files changed

+31
-27
lines changed

6 files changed

+31
-27
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ Here are some things you can do to setup a production environment for your testi
197197

198198
* There are ways of running your tests from Jenkins without having to utilize a remote machine. One way is by using PhantomJS as your browser (it runs headlessly). Another way is by using Xvfb (another headless system). [There's a plugin for Xvfb in Jenkins](https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin). If you have Xvfb running in the background, you can add ``--headless`` to your run command in order to utilize it. For information about the Xvfb plugin for Jenkins, [click here](http://qxf2.com/blog/xvfb-plugin-for-jenkins-selenium/). To see a real-world Jenkins example of headless browser automation in action, [check out the SeleniumBase Google Cloud ReadMe](https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/google_cloud/ReadMe.md), which covers this topic with screenshots.
199199

200-
* If you're using the [SeleniumBase MySQL feature](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mysql_installation.md) to save results from tests running on a server machine, you can install [MySQL Workbench](http://dev.mysql.com/downloads/tools/workbench/) to help you read & write from your DB more easily.
200+
* If you're using the [SeleniumBase MySQL feature](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mysql_installation.md) to save results from tests running on a server machine, you can install [MySQL Workbench](http://dev.mysql.com/downloads/tools/workbench/) to help you read & write from your DB more easily. You'll also need to install the MySQL-Python connector. Depending on your system, you may have to install this a bit differently from the command below:
201+
202+
```bash
203+
pip install MySQL-python==1.2.5
204+
```
201205

202206
* If you use [Slack](https://slack.com), you can easily have your Jenkins jobs display results there by using the [Jenkins Slack Plugin](https://github.com/jenkinsci/slack-plugin). Another way to send messages from your tests to Slack is by using [Slack's Incoming Webhooks API](https://api.slack.com/incoming-webhooks).
203207

help_docs/mysql_installation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Windows:
1515

1616
That installs the MySQL library so that you can use database commands in your code. To make that useful, you'll want to have a MySQL DB that you can connect to.
1717

18+
#### Install the MySQL-Python connector
19+
20+
```bash
21+
pip install MySQL-python==1.2.5
22+
```
23+
1824
#### Access your MySQL DB
1925

2026
If you want a visual tool to help make your MySQL life easier, [try MySQL Workbench](http://dev.mysql.com/downloads/workbench/).

seleniumbase/fixtures/base_case.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ class MyTestClass(BaseCase):
4545
from seleniumbase.fixtures import page_utils
4646
from seleniumbase.fixtures import xpath_to_css
4747
from selenium.common.exceptions import (StaleElementReferenceException,
48-
ElementNotInteractableException,
4948
TimeoutException,
5049
WebDriverException)
50+
from selenium.common import exceptions as selenium_exceptions
51+
try:
52+
# Selenium 3
53+
ENI_Exception = selenium_exceptions.ElementNotInteractableException
54+
except Exception:
55+
# Selenium 2 (Keep compatibility with seleneium 2.53.6 if still being used)
56+
ENI_Exception = selenium_exceptions.ElementNotSelectableException
5157
from selenium.webdriver.remote.webdriver import WebDriver
5258
from selenium.webdriver.common.by import By
5359
from selenium.webdriver.common.keys import Keys
@@ -97,8 +103,7 @@ def click(self, selector, by=By.CSS_SELECTOR,
97103
pre_action_url = self.driver.current_url
98104
try:
99105
element.click()
100-
except (StaleElementReferenceException,
101-
ElementNotInteractableException):
106+
except (StaleElementReferenceException, ENI_Exception):
102107
self.wait_for_ready_state_complete()
103108
time.sleep(0.05)
104109
element = page_actions.wait_for_element_visible(
@@ -129,8 +134,7 @@ def double_click(self, selector, by=By.CSS_SELECTOR,
129134
actions.move_to_element(element)
130135
actions.double_click(element)
131136
actions.perform()
132-
except (StaleElementReferenceException,
133-
ElementNotInteractableException):
137+
except (StaleElementReferenceException, ENI_Exception):
134138
self.wait_for_ready_state_complete()
135139
time.sleep(0.05)
136140
element = page_actions.wait_for_element_visible(
@@ -194,8 +198,7 @@ def click_link_text(self, link_text, timeout=settings.SMALL_TIMEOUT):
194198
pre_action_url = self.driver.current_url
195199
try:
196200
element.click()
197-
except (StaleElementReferenceException,
198-
ElementNotInteractableException):
201+
except (StaleElementReferenceException, ENI_Exception):
199202
self.wait_for_ready_state_complete()
200203
time.sleep(0.05)
201204
element = self.wait_for_link_text_visible(
@@ -251,8 +254,7 @@ def click_partial_link_text(self, partial_link_text,
251254
pre_action_url = self.driver.current_url
252255
try:
253256
element.click()
254-
except (StaleElementReferenceException,
255-
ElementNotInteractableException):
257+
except (StaleElementReferenceException, ENI_Exception):
256258
self.wait_for_ready_state_complete()
257259
time.sleep(0.05)
258260
element = self.wait_for_partial_link_text(
@@ -278,8 +280,7 @@ def get_text(self, selector, by=By.CSS_SELECTOR,
278280
self.driver, selector, by, timeout)
279281
try:
280282
element_text = element.text
281-
except (StaleElementReferenceException,
282-
ElementNotInteractableException):
283+
except (StaleElementReferenceException, ENI_Exception):
283284
self.wait_for_ready_state_complete()
284285
time.sleep(0.06)
285286
element = page_actions.wait_for_element_visible(
@@ -299,8 +300,7 @@ def get_attribute(self, selector, attribute, by=By.CSS_SELECTOR,
299300
self.driver, selector, by, timeout)
300301
try:
301302
attribute_value = element.get_attribute(attribute)
302-
except (StaleElementReferenceException,
303-
ElementNotInteractableException):
303+
except (StaleElementReferenceException, ENI_Exception):
304304
self.wait_for_ready_state_complete()
305305
time.sleep(0.06)
306306
element = page_actions.wait_for_element_present(
@@ -361,8 +361,7 @@ def add_text(self, selector, new_value, by=By.CSS_SELECTOR,
361361
element.send_keys(Keys.RETURN)
362362
if settings.WAIT_FOR_RSC_ON_PAGE_LOADS:
363363
self.wait_for_ready_state_complete()
364-
except (StaleElementReferenceException,
365-
ElementNotInteractableException):
364+
except (StaleElementReferenceException, ENI_Exception):
366365
self.wait_for_ready_state_complete()
367366
time.sleep(0.06)
368367
element = self.wait_for_element_visible(
@@ -411,8 +410,7 @@ def update_text_value(self, selector, new_value, by=By.CSS_SELECTOR,
411410
self._scroll_to_element(element)
412411
try:
413412
element.clear()
414-
except (StaleElementReferenceException,
415-
ElementNotInteractableException):
413+
except (StaleElementReferenceException, ENI_Exception):
416414
self.wait_for_ready_state_complete()
417415
time.sleep(0.06)
418416
element = self.wait_for_element_visible(
@@ -429,8 +427,7 @@ def update_text_value(self, selector, new_value, by=By.CSS_SELECTOR,
429427
element.send_keys(Keys.RETURN)
430428
if settings.WAIT_FOR_RSC_ON_PAGE_LOADS:
431429
self.wait_for_ready_state_complete()
432-
except (StaleElementReferenceException,
433-
ElementNotInteractableException):
430+
except (StaleElementReferenceException, ENI_Exception):
434431
self.wait_for_ready_state_complete()
435432
time.sleep(0.06)
436433
element = self.wait_for_element_visible(
@@ -631,8 +628,7 @@ def scroll_to(self, selector, by=By.CSS_SELECTOR,
631628
selector, by=by, timeout=timeout)
632629
try:
633630
self._scroll_to_element(element)
634-
except (StaleElementReferenceException,
635-
ElementNotInteractableException):
631+
except (StaleElementReferenceException, ENI_Exception):
636632
self.wait_for_ready_state_complete()
637633
time.sleep(0.05)
638634
element = self.wait_for_element_visible(
@@ -1274,8 +1270,7 @@ def _pick_select_option(self, dropdown_selector, option,
12741270
Select(element).select_by_value(option)
12751271
else:
12761272
Select(element).select_by_visible_text(option)
1277-
except (StaleElementReferenceException,
1278-
ElementNotInteractableException):
1273+
except (StaleElementReferenceException, ENI_Exception):
12791274
self.wait_for_ready_state_complete()
12801275
time.sleep(0.05)
12811276
element = self.find_element(

server_requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ chardet==3.0.4
1414
boto==2.48.0
1515
ipdb==0.10.2
1616
pyvirtualdisplay==0.2.1
17-
MySQL-python==1.2.5

server_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='seleniumbase',
11-
version='1.5.1',
11+
version='1.5.2',
1212
description='Web Automation & Testing Framework - http://seleniumbase.com',
1313
long_description='Web Automation and Testing Framework - seleniumbase.com',
1414
platforms='Mac * Windows * Linux * Docker',

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='seleniumbase',
11-
version='1.5.1',
11+
version='1.5.2',
1212
description='Web Automation & Testing Framework - http://seleniumbase.com',
1313
long_description='Web Automation and Testing Framework - seleniumbase.com',
1414
platforms='Mac * Windows * Linux * Docker',

0 commit comments

Comments
 (0)