Skip to content

Compatibility with selenium 2 #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ Here are some things you can do to setup a production environment for your testi

* 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.

* 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.
* 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:

```bash
pip install MySQL-python==1.2.5
```

* 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).

Expand Down
6 changes: 6 additions & 0 deletions help_docs/mysql_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Windows:

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.

#### Install the MySQL-Python connector

```bash
pip install MySQL-python==1.2.5
```

#### Access your MySQL DB

If you want a visual tool to help make your MySQL life easier, [try MySQL Workbench](http://dev.mysql.com/downloads/workbench/).
Expand Down
41 changes: 18 additions & 23 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ class MyTestClass(BaseCase):
from seleniumbase.fixtures import page_utils
from seleniumbase.fixtures import xpath_to_css
from selenium.common.exceptions import (StaleElementReferenceException,
ElementNotInteractableException,
TimeoutException,
WebDriverException)
from selenium.common import exceptions as selenium_exceptions
try:
# Selenium 3
ENI_Exception = selenium_exceptions.ElementNotInteractableException
except Exception:
# Selenium 2 (Keep compatibility with seleneium 2.53.6 if still being used)
ENI_Exception = selenium_exceptions.ElementNotSelectableException
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
Expand Down Expand Up @@ -97,8 +103,7 @@ def click(self, selector, by=By.CSS_SELECTOR,
pre_action_url = self.driver.current_url
try:
element.click()
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.05)
element = page_actions.wait_for_element_visible(
Expand Down Expand Up @@ -129,8 +134,7 @@ def double_click(self, selector, by=By.CSS_SELECTOR,
actions.move_to_element(element)
actions.double_click(element)
actions.perform()
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.05)
element = page_actions.wait_for_element_visible(
Expand Down Expand Up @@ -194,8 +198,7 @@ def click_link_text(self, link_text, timeout=settings.SMALL_TIMEOUT):
pre_action_url = self.driver.current_url
try:
element.click()
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.05)
element = self.wait_for_link_text_visible(
Expand Down Expand Up @@ -251,8 +254,7 @@ def click_partial_link_text(self, partial_link_text,
pre_action_url = self.driver.current_url
try:
element.click()
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.05)
element = self.wait_for_partial_link_text(
Expand All @@ -278,8 +280,7 @@ def get_text(self, selector, by=By.CSS_SELECTOR,
self.driver, selector, by, timeout)
try:
element_text = element.text
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.06)
element = page_actions.wait_for_element_visible(
Expand All @@ -299,8 +300,7 @@ def get_attribute(self, selector, attribute, by=By.CSS_SELECTOR,
self.driver, selector, by, timeout)
try:
attribute_value = element.get_attribute(attribute)
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.06)
element = page_actions.wait_for_element_present(
Expand Down Expand Up @@ -361,8 +361,7 @@ def add_text(self, selector, new_value, by=By.CSS_SELECTOR,
element.send_keys(Keys.RETURN)
if settings.WAIT_FOR_RSC_ON_PAGE_LOADS:
self.wait_for_ready_state_complete()
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.06)
element = self.wait_for_element_visible(
Expand Down Expand Up @@ -411,8 +410,7 @@ def update_text_value(self, selector, new_value, by=By.CSS_SELECTOR,
self._scroll_to_element(element)
try:
element.clear()
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.06)
element = self.wait_for_element_visible(
Expand All @@ -429,8 +427,7 @@ def update_text_value(self, selector, new_value, by=By.CSS_SELECTOR,
element.send_keys(Keys.RETURN)
if settings.WAIT_FOR_RSC_ON_PAGE_LOADS:
self.wait_for_ready_state_complete()
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.06)
element = self.wait_for_element_visible(
Expand Down Expand Up @@ -631,8 +628,7 @@ def scroll_to(self, selector, by=By.CSS_SELECTOR,
selector, by=by, timeout=timeout)
try:
self._scroll_to_element(element)
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.05)
element = self.wait_for_element_visible(
Expand Down Expand Up @@ -1274,8 +1270,7 @@ def _pick_select_option(self, dropdown_selector, option,
Select(element).select_by_value(option)
else:
Select(element).select_by_visible_text(option)
except (StaleElementReferenceException,
ElementNotInteractableException):
except (StaleElementReferenceException, ENI_Exception):
self.wait_for_ready_state_complete()
time.sleep(0.05)
element = self.find_element(
Expand Down
1 change: 0 additions & 1 deletion server_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ chardet==3.0.4
boto==2.48.0
ipdb==0.10.2
pyvirtualdisplay==0.2.1
MySQL-python==1.2.5
2 changes: 1 addition & 1 deletion server_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='seleniumbase',
version='1.5.1',
version='1.5.2',
description='Web Automation & Testing Framework - http://seleniumbase.com',
long_description='Web Automation and Testing Framework - seleniumbase.com',
platforms='Mac * Windows * Linux * Docker',
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='seleniumbase',
version='1.5.1',
version='1.5.2',
description='Web Automation & Testing Framework - http://seleniumbase.com',
long_description='Web Automation and Testing Framework - seleniumbase.com',
platforms='Mac * Windows * Linux * Docker',
Expand Down