Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
835e44e
Upgrade to Selenium 3 and update the requirements
mdmintz Mar 10, 2017
97b05b4
Ignore Geckodriver logs in git commits
mdmintz Mar 10, 2017
8cd946f
Text alignment
mdmintz Mar 10, 2017
1d49d23
Chrome is now the default web browser when unspecified
mdmintz Mar 10, 2017
fc02fd3
Better than "Ready State: Complete" to be safe.
mdmintz Mar 10, 2017
b945f95
Update documentation
mdmintz Mar 10, 2017
a677fe9
Flake8 spacing
mdmintz Mar 10, 2017
fafc3fb
Set default desired capabilities
mdmintz Mar 10, 2017
cb16263
Add Geckodriver installation to Dockerfile
mdmintz Mar 10, 2017
2d0afcf
Add Geckodriver installation to Linuxfile
mdmintz Mar 10, 2017
3a0fe6d
Use self.assertTrue() instead of assert() in example test
mdmintz Mar 10, 2017
790184b
Putting the Chrome verification before Firefox
mdmintz Mar 10, 2017
16bd438
Handle StaleElementReferenceException gracefully
mdmintz Mar 10, 2017
eaff759
Slight wording change
mdmintz Mar 10, 2017
bcc2f38
Make waiting for "Ready State: Complete" the default
mdmintz Mar 10, 2017
ad0b4df
Work around a Geckodriver bug dealing with pop-up alerts
mdmintz Mar 10, 2017
2058793
Version 1.3.0
mdmintz Mar 10, 2017
33dbe9f
Update the ReadMe
mdmintz Mar 10, 2017
ca12994
Update the Linuxfile
mdmintz Mar 10, 2017
601e636
Try chrome for travis.yml selenium
mdmintz Mar 10, 2017
3e3d7b4
travis.yml chrome update
mdmintz Mar 10, 2017
16d2ee6
Update chromedriver link
mdmintz Mar 10, 2017
2eef1a9
update travis.yml
mdmintz Mar 10, 2017
a4b9d74
Update travis.yml
mdmintz Mar 10, 2017
6bcf504
Update travis.yml
mdmintz Mar 10, 2017
5cc754a
Update travis.yml
mdmintz Mar 10, 2017
ba5c14d
Linux compatibility
mdmintz Mar 10, 2017
7094662
Remove an unused requirement
mdmintz Mar 10, 2017
c8d73c5
Comments
mdmintz Mar 10, 2017
fd40762
Remove an unused requirement
mdmintz Mar 10, 2017
ae81202
Avoid Geckodriver for Linux machine setup
mdmintz Mar 10, 2017
b039c3f
Update a ReadMe
mdmintz Mar 10, 2017
5c40aa4
Use the latest version of Chromedriver in the Linuxfile
mdmintz Mar 10, 2017
20d3175
Flake8 all the files for .travis.yml
mdmintz Mar 10, 2017
7bba712
Docker updates
mdmintz Mar 10, 2017
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ nosetests.xml

# Other
selenium-server-standalone.jar
geckodriver.log
downloaded_files
archived_files
logs
Expand Down
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ python:
- "2.7"
install:
- "pip install --upgrade pip"
- "pip install -r requirements.txt"
- "python setup.py install"
- "pip install -r server_requirements.txt"
- "python server_setup.py install"
before_script:
- "flake8 seleniumbase/*.py"
- "flake8 seleniumbase/*/*.py"
- "flake8 seleniumbase/*/*/*.py"
- "flake8 seleniumbase/*/*/*/*.py"
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
script:
Expand Down
20 changes: 17 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ RUN apt-get -qy --no-install-recommends install \
&& ln -s /opt/firefox/firefox /usr/bin/firefox \
&& rm -f /tmp/firefox-esr.tar.bz2

#======================================
# Install Geckodriver / Firefox Driver
#======================================
RUN export BASE_URL=https://github.com/mozilla/geckodriver/releases/download \
&& export VERSION=$(curl -sL \
https://api.github.com/repos/mozilla/geckodriver/releases/latest | \
grep tag_name | cut -d '"' -f 4) \
&& curl -sL \
$BASE_URL/$VERSION/geckodriver-$VERSION-linux64.tar.gz | tar -xz \
&& mv geckodriver /usr/local/bin/geckodriver

#===================
# Install PhantomJS
#===================
Expand All @@ -96,9 +107,12 @@ RUN exec "$@"
#=====================
COPY seleniumbase /SeleniumBase/seleniumbase/
COPY examples /SeleniumBase/examples/
COPY requirements.txt /SeleniumBase/requirements.txt
COPY setup.py /SeleniumBase/setup.py
RUN cd /SeleniumBase && ls && pip install -r requirements.txt
COPY docker_requirements.txt /SeleniumBase/docker_requirements.txt
COPY server_setup.py /SeleniumBase/server_setup.py
RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
RUN cd /SeleniumBase && ls && pip install -r docker_requirements.txt
RUN cd /SeleniumBase && python server_setup.py install

#==========================================
# Create entrypoint and grab example tests
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![pypi](https://img.shields.io/pypi/v/seleniumbase.svg)](https://pypi.python.org/pypi/seleniumbase) [![Build Status](https://travis-ci.org/seleniumbase/SeleniumBase.svg?branch=master)](https://travis-ci.org/seleniumbase/SeleniumBase) [![GitHub stars](https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg "GitHub stars")](https://github.com/seleniumbase/SeleniumBase/stargazers) [![Python version](https://img.shields.io/badge/python-2.7-22AADD.svg "Python version")](https://docs.python.org/2/) [![MIT License](http://img.shields.io/badge/license-MIT-22BBCC.svg "MIT License")](https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE) [![Join the chat at https://gitter.im/seleniumbase/SeleniumBase](https://badges.gitter.im/seleniumbase/SeleniumBase.svg)](https://gitter.im/seleniumbase/SeleniumBase?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

**Automation Platform for Testing and Business**
**Web Automation Platform for Testing and More**

(And the power to [speed up your manual testing](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/masterqa/ReadMe.md))
(And the power to [speed up manual testing](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/masterqa/ReadMe.md))

![](http://cdn2.hubspot.net/hubfs/100006/images/sb_demo.gif "SeleniumBase")

Expand All @@ -29,13 +29,19 @@ SeleniumBase makes it easy to automate tedious business tasks. (*To learn about

* To install ``python``, ``pip``, ``git``, and either ``virtualenv`` or ``virtualenvwrapper``, **[follow these instructions](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/requirements_installation.md)**.

* Download web browsers such as [Chrome](https://www.google.com/chrome/browser/desktop/index.html) (or [Chromium](https://download-chromium.appspot.com/)) and also [Firefox v46.*](https://ftp.mozilla.org/pub/firefox/releases/46.0.1/) (or [Firefox ESR](https://www.mozilla.org/en-US/firefox/organizations/)) because Firefox versions 47.0 and above are no longer compatible with normal Selenium WebDriver. (If you go with Firefox 46.*, make sure to turn off auto-updates or else you'll be back at v47+ quickly!)
* Download web browsers such as [Chrome](https://www.google.com/chrome/browser/desktop/index.html) (or [Chromium](https://download-chromium.appspot.com/)) and [Firefox](https://www.mozilla.org/firefox/new/).

(NOTE: Firefox versions 47.0 and above are no longer compatible with normal Selenium WebDriver. [Get Firefox 46.*](https://ftp.mozilla.org/pub/firefox/releases/46.0.1/) instead, or you can [Get Firefox ESR](https://www.mozilla.org/en-US/firefox/organizations/). (If you go with Firefox 46.*, make sure to turn off auto-updates or else you'll be back at v47 quickly!) For more information regarding this, [read this post](http://stackoverflow.com/questions/37693106/selenium-2-53-not-working-on-firefox-47) from Stack Overflow. There's a [new version of Firefox driver](https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver) coming soon.
To run automation on various web browsers, you'll need to download a driver file for each one and place it on your System **[PATH](http://java.com/en/download/help/path.xml)**:

* If you want to run automation on browsers other than Firefox, you'll need to download [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads), [PhantomJS](http://phantomjs.org/download.html), [Edge Driver (Microsoft WebDriver)](https://www.microsoft.com/en-us/download/details.aspx?id=48212), and/or [Safari Driver](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/using_safari_driver.md) separately. (Firefox drivers come with Selenium by default.)
* For Chrome, get [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) on your System Path.

* For everything you download (such as ``pip`` and ``Chromedriver``) make sure those files get on your system [PATH](http://java.com/en/download/help/path.xml). (``Environmental Variables`` on a Windows machine)
* For Firefox, get [Geckodriver](https://github.com/mozilla/geckodriver/releases) on your System Path.

* For Microsoft Edge, get [Edge Driver (Microsoft WebDriver)](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/) on your System Path.

* For Safari, get [Safari Driver](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/using_safari_driver.md) on your System Path.

* For PhantomJS headless browser automation, get [PhantomJS](http://phantomjs.org/download.html) on your System Path.

Mac:

Expand Down Expand Up @@ -124,7 +130,7 @@ nosetests my_first_test.py --with-selenium --browser=firefox -s
nosetests my_first_test.py --with-selenium --browser=phantomjs -s
```

After the test completes, in the console output you'll see a dot (``.``) on a new line, representing a passing test. (On test failures you'll see an ``F`` instead, and on test errors you'll see an ``E``). It looks more like a moving progress bar when you're running a ton of unit tests side by side. This is part of nosetests. After all tests complete (in this case there is only one), you'll see the "``Ran 1 test in ...``" line, followed by an "``OK``" if all nosetests passed. The ``--with-selenium`` option is required for running GUI tests. If no browser is specified, Firefox will become the default. The ``-s`` option is optional, and that makes sure that any standard output is printed immediately on the command line when tests have print statements in them, which makes debugging much easier.
After the test completes, in the console output you'll see a dot (``.``) on a new line, representing a passing test. (On test failures you'll see an ``F`` instead, and on test errors you'll see an ``E``). It looks more like a moving progress bar when you're running a ton of unit tests side by side. This is part of nosetests. After all tests complete (in this case there is only one), you'll see the "``Ran 1 test in ...``" line, followed by an "``OK``" if all nosetests passed. The ``--with-selenium`` option is required for running GUI tests. If no browser is specified, Chrome will become the default. The ``-s`` option is optional, and that makes sure that any standard output is printed immediately on the command line when tests have print statements in them, which makes debugging much easier.

NOTE: The following two lines of code can be simplified...
``` python
Expand Down
8 changes: 4 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def pytest_addoption(parser):
parser.addoption('--browser', action="store",
dest='browser',
choices=constants.Browser.VERSION.keys(),
default=constants.Browser.FIREFOX,
help="""Specifies the web browser to use. Default=FireFox.
If you want to use Chrome, explicitly indicate that.
Example: (--browser=chrome)""")
default=constants.Browser.GOOGLE_CHROME,
help="""Specifies the web browser to use. Default: Chrome.
If you want to use Firefox, explicitly indicate that.
Example: (--browser=firefox)""")
parser.addoption('--is_pytest', action="store_true",
dest='is_pytest',
default=True,
Expand Down
15 changes: 15 additions & 0 deletions docker_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pip>=9.0.1
setuptools>=34.3.1
selenium==2.53.6
nose>=1.3.7
pytest>=3.0.6
six>=1.10.0
flake8==3.3.0
requests==2.13.0
urllib3==1.20
BeautifulSoup==3.2.1
unittest2==1.1.0
chardet==2.3.0
boto==2.46.1
ipdb==0.10.2
pyvirtualdisplay==0.2.1
1 change: 1 addition & 0 deletions examples/gui_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def run_7(self):
'nosetests my_test_suite.py --with-selenium'
' --browser=chrome --with-db_reporting')


if __name__ == "__main__":
root = Tk()
root.minsize(612, 444)
Expand Down
4 changes: 2 additions & 2 deletions examples/my_first_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ def test_basic(self):
self.assert_element('img[alt="Python"]') # Asserts element on page
self.click('a[rel="license"]') # Clicks element on page
xkcd_license = self.get_text('center') # Gets text from page element
assert('reuse any of my drawings' in xkcd_license)
self.assertTrue('reuse any of my drawings' in xkcd_license)
self.open('http://xkcd.com/1481/')
image_object = self.find_element('#comic img') # Returns the element
caption = image_object.get_attribute('title') # Gets attr from element
assert('connections to the server' in caption)
self.assertTrue('connections to the server' in caption)
self.click_link_text('Blag') # Clicks link containing the text
self.assert_text('The blag', 'header h2') # Asserts text in element
self.update_text('input#s', 'Robots!\n') # Updates textfield with text
Expand Down
20 changes: 14 additions & 6 deletions help_docs/requirements_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@

### [Python 2.7](https://www.python.org/downloads/)

If you're a MAC user, that should already come preinstalled on your machine. Although Python 3 exists, you'll want Python 2 (both of these major versions are being improved in parallel). Python 2.7.10 is the one I've been using on my Mac.
If you're a MAC user, that should already come preinstalled on your machine. Although Python 3 exists, you'll want Python 2 (both of these major versions are being improved in parallel). Python 2.7.13 is the one I've been using on my Mac.

If you're a WINDOWS user, [download the latest 2.* version from here](https://www.python.org/downloads/release/python-2710/).
If you're a WINDOWS user, [download the latest 2.* version from here](https://www.python.org/downloads/release/python-2713/).

### [Pip](https://en.wikipedia.org/wiki/Pip_%28package_manager%29)

If "pip" did not come with your Python installation, you can [GET PIP HERE](https://pip.pypa.io/en/latest/installing/).
### [Pip](https://en.wikipedia.org/wiki/Pip_%28package_manager%29)

On a MAC, you can also install pip easily with the following command:
On a MAC, run the following command:
```bash
sudo easy_install pip
```
Then make sure it's on your path.

On WINDOWS, run the following command:
```bash
python -m pip install -U pip setuptools
```

If you're having any trouble with that, you can [GET PIP HERE](https://pip.pypa.io/en/latest/installing/).

When done, make sure pip is on your path. ($PATH on Mac/Linux. System Environment Variables on WINDOWS.)


### [Homebrew](http://brew.sh/) (MAC-ONLY) (OPTIONAL)

Expand Down
8 changes: 4 additions & 4 deletions help_docs/verify_webdriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

*You can do this by checking inside a Python command prompt. (NOTE: xkcd is a webcomic)*

#### Verifying FirefoxDriver (comes with Selenium by default)
#### Verifying ChromeDriver
```bash
python
>>> from selenium import webdriver
>>> browser = webdriver.Firefox()
>>> browser = webdriver.Chrome()
>>> browser.get("http://xkcd.com/1337/")
>>> browser.close()
>>> exit()
```

#### Verifying ChromeDriver (you had to install this separately)
#### Verifying FirefoxDriver (Geckodriver)
```bash
python
>>> from selenium import webdriver
>>> browser = webdriver.Chrome()
>>> browser = webdriver.Firefox()
>>> browser.get("http://xkcd.com/1337/")
>>> browser.close()
>>> exit()
Expand Down
2 changes: 1 addition & 1 deletion integrations/google_cloud/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ sudo pip install -r server_requirements.txt --upgrade
#### Step 12. Install SeleniumBase (Make sure you already installed the requirements above)

```bash
sudo python setup.py install
sudo python server_setup.py install
```

#### Step 13. Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) in Chrome to verify installation (Takes ~10 seconds)
Expand Down
2 changes: 1 addition & 1 deletion integrations/linux/Linuxfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ sudo apt-get -f install -y --force-yes
sudo dpkg -i google-chrome-stable_current_amd64.deb

# Install Chromedriver
sudo wget -N http://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip -P ~/Downloads
sudo wget -N http://chromedriver.storage.googleapis.com/2.28/chromedriver_linux64.zip -P ~/Downloads
sudo unzip -o ~/Downloads/chromedriver_linux64.zip -d ~/Downloads
sudo chmod +x ~/Downloads/chromedriver
sudo rm -f /usr/local/share/chromedriver
Expand Down
21 changes: 10 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
pip>=8.1.2
setuptools>=28.2.0
selenium==2.53.6
pip>=9.0.1
setuptools>=34.3.1
selenium==3.3.0
nose>=1.3.7
pytest>=3.0.2
pytest>=3.0.6
six>=1.10.0
flake8==3.0.4
requests==2.11.1
urllib3==1.17
flake8==3.3.0
requests==2.13.0
urllib3==1.20
BeautifulSoup==3.2.1
unittest2==1.1.0
chardet==2.3.0
simplejson==3.8.2
boto==2.42.0
ipdb==0.9.4
pyvirtualdisplay==0.2
boto==2.46.1
ipdb==0.10.2
pyvirtualdisplay==0.2.1
-e .
16 changes: 9 additions & 7 deletions seleniumbase/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@
HTML_REPORT = "report.html"
RESULTS_TABLE = "results_table.csv"

''' This adds wait_for_ready_state_complete() after various browser actions.
By default, Selenium waits for the 'interactive' state before continuing.
Setting this to True may improve reliability at the cost of speed.
WARNING: Some websites are in a perpetual "interactive" state due to
dynamic content that never fully finishes loading (Use "False" there). '''
'''
This adds wait_for_ready_state_complete() after various browser actions.
By default, Selenium waits for the 'interactive' state before continuing.
Setting this to True may improve reliability at the cost of speed.
WARNING: Some websites are in a perpetual "interactive" state due to
dynamic content that never fully finishes loading (Use "False" there).
'''
# Called after self.open(url) or self.open_url(url), NOT self.driver.open(url)
WAIT_FOR_RSC_ON_PAGE_LOADS = False
WAIT_FOR_RSC_ON_PAGE_LOADS = True
# Called after self.click(selector), NOT element.click()
WAIT_FOR_RSC_ON_CLICKS = False
WAIT_FOR_RSC_ON_CLICKS = True


# #####>>>>>----- MasterQA SETTINGS -----<<<<<#####
Expand Down
5 changes: 4 additions & 1 deletion seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from selenium import webdriver
from seleniumbase.core import download_helper
from seleniumbase.fixtures import constants
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities


def get_driver(browser_name):
Expand Down Expand Up @@ -31,7 +32,9 @@ def get_driver(browser_name):
("application/pdf, application/zip, application/octet-stream, "
"text/csv, text/xml, application/xml, text/plain, "
"text/octet-stream"))
return webdriver.Firefox(profile)
firefox_capabilities = DesiredCapabilities.FIREFOX
return webdriver.Firefox(
firefox_profile=profile, capabilities=firefox_capabilities)
except:
return webdriver.Firefox()
if browser_name == constants.Browser.INTERNET_EXPLORER:
Expand Down
1 change: 1 addition & 0 deletions seleniumbase/core/mysql_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class Apps:
TESTCASE_REPOSITORY = "testcase_repository"


APP_CREDS = {

Apps.TESTCASE_REPOSITORY: {
Expand Down
Loading