Skip to content

Commit 45da8a7

Browse files
authored
Merge pull request #73 from seleniumbase/selenium-3-migration
Selenium 3 migration
2 parents 824717c + 7bba712 commit 45da8a7

23 files changed

+348
-128
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ nosetests.xml
3636

3737
# Other
3838
selenium-server-standalone.jar
39+
geckodriver.log
3940
downloaded_files
4041
archived_files
4142
logs

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ python:
44
- "2.7"
55
install:
66
- "pip install --upgrade pip"
7-
- "pip install -r requirements.txt"
8-
- "python setup.py install"
7+
- "pip install -r server_requirements.txt"
8+
- "python server_setup.py install"
99
before_script:
10+
- "flake8 seleniumbase/*.py"
1011
- "flake8 seleniumbase/*/*.py"
12+
- "flake8 seleniumbase/*/*/*.py"
13+
- "flake8 seleniumbase/*/*/*/*.py"
1114
- "export DISPLAY=:99.0"
1215
- "sh -e /etc/init.d/xvfb start"
1316
script:

Dockerfile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ RUN apt-get -qy --no-install-recommends install \
7373
&& ln -s /opt/firefox/firefox /usr/bin/firefox \
7474
&& rm -f /tmp/firefox-esr.tar.bz2
7575

76+
#======================================
77+
# Install Geckodriver / Firefox Driver
78+
#======================================
79+
RUN export BASE_URL=https://github.com/mozilla/geckodriver/releases/download \
80+
&& export VERSION=$(curl -sL \
81+
https://api.github.com/repos/mozilla/geckodriver/releases/latest | \
82+
grep tag_name | cut -d '"' -f 4) \
83+
&& curl -sL \
84+
$BASE_URL/$VERSION/geckodriver-$VERSION-linux64.tar.gz | tar -xz \
85+
&& mv geckodriver /usr/local/bin/geckodriver
86+
7687
#===================
7788
# Install PhantomJS
7889
#===================
@@ -96,9 +107,12 @@ RUN exec "$@"
96107
#=====================
97108
COPY seleniumbase /SeleniumBase/seleniumbase/
98109
COPY examples /SeleniumBase/examples/
99-
COPY requirements.txt /SeleniumBase/requirements.txt
100-
COPY setup.py /SeleniumBase/setup.py
101-
RUN cd /SeleniumBase && ls && pip install -r requirements.txt
110+
COPY docker_requirements.txt /SeleniumBase/docker_requirements.txt
111+
COPY server_setup.py /SeleniumBase/server_setup.py
112+
RUN pip install --upgrade pip
113+
RUN pip install --upgrade setuptools
114+
RUN cd /SeleniumBase && ls && pip install -r docker_requirements.txt
115+
RUN cd /SeleniumBase && python server_setup.py install
102116

103117
#==========================================
104118
# Create entrypoint and grab example tests

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
[![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)
44

5-
**Automation Platform for Testing and Business**
5+
**Web Automation Platform for Testing and More**
66

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

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

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

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

32-
* 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!)
32+
* 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/).
3333

34-
(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.
34+
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)**:
3535

36-
* 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.)
36+
* For Chrome, get [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) on your System Path.
3737

38-
* 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)
38+
* For Firefox, get [Geckodriver](https://github.com/mozilla/geckodriver/releases) on your System Path.
39+
40+
* For Microsoft Edge, get [Edge Driver (Microsoft WebDriver)](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/) on your System Path.
41+
42+
* For Safari, get [Safari Driver](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/using_safari_driver.md) on your System Path.
43+
44+
* For PhantomJS headless browser automation, get [PhantomJS](http://phantomjs.org/download.html) on your System Path.
3945

4046
Mac:
4147

@@ -124,7 +130,7 @@ nosetests my_first_test.py --with-selenium --browser=firefox -s
124130
nosetests my_first_test.py --with-selenium --browser=phantomjs -s
125131
```
126132

127-
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.
133+
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.
128134

129135
NOTE: The following two lines of code can be simplified...
130136
``` python

conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ def pytest_addoption(parser):
1212
parser.addoption('--browser', action="store",
1313
dest='browser',
1414
choices=constants.Browser.VERSION.keys(),
15-
default=constants.Browser.FIREFOX,
16-
help="""Specifies the web browser to use. Default=FireFox.
17-
If you want to use Chrome, explicitly indicate that.
18-
Example: (--browser=chrome)""")
15+
default=constants.Browser.GOOGLE_CHROME,
16+
help="""Specifies the web browser to use. Default: Chrome.
17+
If you want to use Firefox, explicitly indicate that.
18+
Example: (--browser=firefox)""")
1919
parser.addoption('--is_pytest', action="store_true",
2020
dest='is_pytest',
2121
default=True,

docker_requirements.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pip>=9.0.1
2+
setuptools>=34.3.1
3+
selenium==2.53.6
4+
nose>=1.3.7
5+
pytest>=3.0.6
6+
six>=1.10.0
7+
flake8==3.3.0
8+
requests==2.13.0
9+
urllib3==1.20
10+
BeautifulSoup==3.2.1
11+
unittest2==1.1.0
12+
chardet==2.3.0
13+
boto==2.46.1
14+
ipdb==0.10.2
15+
pyvirtualdisplay==0.2.1

examples/gui_test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def run_7(self):
101101
'nosetests my_test_suite.py --with-selenium'
102102
' --browser=chrome --with-db_reporting')
103103

104+
104105
if __name__ == "__main__":
105106
root = Tk()
106107
root.minsize(612, 444)

examples/my_first_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def test_basic(self):
88
self.assert_element('img[alt="Python"]') # Asserts element on page
99
self.click('a[rel="license"]') # Clicks element on page
1010
xkcd_license = self.get_text('center') # Gets text from page element
11-
assert('reuse any of my drawings' in xkcd_license)
11+
self.assertTrue('reuse any of my drawings' in xkcd_license)
1212
self.open('http://xkcd.com/1481/')
1313
image_object = self.find_element('#comic img') # Returns the element
1414
caption = image_object.get_attribute('title') # Gets attr from element
15-
assert('connections to the server' in caption)
15+
self.assertTrue('connections to the server' in caption)
1616
self.click_link_text('Blag') # Clicks link containing the text
1717
self.assert_text('The blag', 'header h2') # Asserts text in element
1818
self.update_text('input#s', 'Robots!\n') # Updates textfield with text

help_docs/requirements_installation.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,27 @@
33

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

6-
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.
6+
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.
77

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

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

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

14-
On a MAC, you can also install pip easily with the following command:
13+
On a MAC, run the following command:
1514
```bash
1615
sudo easy_install pip
1716
```
18-
Then make sure it's on your path.
17+
18+
On WINDOWS, run the following command:
19+
```bash
20+
python -m pip install -U pip setuptools
21+
```
22+
23+
If you're having any trouble with that, you can [GET PIP HERE](https://pip.pypa.io/en/latest/installing/).
24+
25+
When done, make sure pip is on your path. ($PATH on Mac/Linux. System Environment Variables on WINDOWS.)
26+
1927

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

help_docs/verify_webdriver.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

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

5-
#### Verifying FirefoxDriver (comes with Selenium by default)
5+
#### Verifying ChromeDriver
66
```bash
77
python
88
>>> from selenium import webdriver
9-
>>> browser = webdriver.Firefox()
9+
>>> browser = webdriver.Chrome()
1010
>>> browser.get("http://xkcd.com/1337/")
1111
>>> browser.close()
1212
>>> exit()
1313
```
1414

15-
#### Verifying ChromeDriver (you had to install this separately)
15+
#### Verifying FirefoxDriver (Geckodriver)
1616
```bash
1717
python
1818
>>> from selenium import webdriver
19-
>>> browser = webdriver.Chrome()
19+
>>> browser = webdriver.Firefox()
2020
>>> browser.get("http://xkcd.com/1337/")
2121
>>> browser.close()
2222
>>> exit()

0 commit comments

Comments
 (0)