Skip to content

Commit 9303f3f

Browse files
authored
Merge pull request #152 from seleniumbase/update-simplify-reqs-and-add-drivers
Update/simplify requirements and add extra drivers option.
2 parents ce7b83a + 93dc550 commit 9303f3f

14 files changed

+140
-164
lines changed

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="https://cdn2.hubspot.net/hubfs/100006/images/expanded_icons2f.png" title="SeleniumBase" align="left" padding="1px" height="100" margin="1px 1px" hspace="2px">
22

3-
Browser automated testing with Python done efficiently.<br />
3+
Automated Web-UI testing with Python, made awesome.<br />
44

55
[![](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)<br /><br>
66

@@ -65,7 +65,7 @@ SeleniumBase was originally built for [testing HubSpot's platform](https://produ
6565

6666
## Get Started:
6767

68-
(Before installation, **[install Python](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/install_python_pip_git.md)** and **[get WebDriver](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/webdriver_installation.md)** on your system PATH.)
68+
Before installation, **[install Python](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/install_python_pip_git.md)** and **[get a WebDriver](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/webdriver_installation.md)** on your system PATH.
6969

7070

7171
### ![http://seleniumbase.com](https://cdn2.hubspot.net/hubfs/100006/images/super_logo_tiny.png "SeleniumBase") **Step 1:** Clone SeleniumBase
@@ -79,30 +79,33 @@ cd SeleniumBase
7979
(<i>A [Git](https://git-scm.com/) GUI tool like [SourceTree](http://www.sourcetreeapp.com/) may help.</i>)
8080

8181

82-
### ![http://seleniumbase.com](https://cdn2.hubspot.net/hubfs/100006/images/super_logo_tiny.png "SeleniumBase") **Step 2:** Create a Virtual Env.
82+
### ![http://seleniumbase.com](https://cdn2.hubspot.net/hubfs/100006/images/super_logo_tiny.png "SeleniumBase") **Step 2:** Create a Virtual Environment
8383

8484
(OPTIONAL) To learn how to create a Python virtual environment, [see this ReadMe](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md).
8585

8686

8787
### ![http://seleniumbase.com](https://cdn2.hubspot.net/hubfs/100006/images/super_logo_tiny.png "SeleniumBase") **Step 3:** Install SeleniumBase
8888

89-
Run the following commands from the top-level SeleniumBase folder:
89+
If you're installing SeleniumBase from a cloned copy on your machine, use:
9090
```
9191
pip install -r requirements.txt
9292
9393
python setup.py develop
9494
```
9595

96-
If you already have an older version installed, add ``--upgrade`` to the ``pip`` command in order to update previously-installed Python packages. If you're not using a virtual environment, you may need to add ``--user`` to the end of your ``pip`` command. (<i>Do that if you see any errors during installation.</i>)
97-
98-
(<i>If you can't install ChromeDriver or GeckoDriver, use `server_requirements.txt` and `server_setup.py` to run tests using the older Selenium 2.53.6 on a version of Firefox that's older than 47.</i>)
99-
100-
To install SeleniumBase from the [Python Package Index](https://pypi.python.org/pypi/seleniumbase) use the following command: (Add ``--upgrade`` and/or ``--user`` to the command as needed.)
96+
If you're installing SeleniumBase from the [Python Package Index](https://pypi.python.org/pypi/seleniumbase), use:
10197
```bash
10298
pip install seleniumbase
10399
```
104100

105-
(NOTE: If you're using Python 3.x instead of Python 2.7, use ``pip3`` in place of ``pip`` and ``python3`` in place of ``python`` in the above commands.)
101+
If you're installing SeleniumBase directly from GitHub, use:
102+
```bash
103+
pip install -e git+https://github.com/seleniumbase/SeleniumBase.git@master#egg=seleniumbase
104+
```
105+
106+
(If you already have an older version installed, you may want to add ``--upgrade`` to your ``pip`` command to update existing Python packages. If you're not using a virtual environment, you may need to add ``--user`` to your ``pip`` command if you're getting errors during installation.)
107+
108+
(If you want to use Python 3.x instead of Python 2.7, use ``pip3`` in place of ``pip`` and ``python3`` in place of ``python``.)
106109

107110

108111
<a id="seleniumbase_basic_usage"></a>
@@ -119,12 +122,11 @@ class MyTestClass(BaseCase):
119122
self.open('http://xkcd.com/353/')
120123
self.assert_element('img[alt="Python"]')
121124
self.click('a[rel="license"]')
122-
text = self.get_text("div center")
123-
self.assertTrue("reuse any of my drawings" in text)
124-
self.open('http://xkcd.com/1481/')
125-
title = self.get_attribute('#comic img', 'title')
126-
self.assertTrue('connections to the server' in title)
127-
self.click_link_text('Blag')
125+
self.assert_text('free to copy', 'div center')
126+
self.open("http://xkcd.com/1481/")
127+
title = self.get_attribute("#comic img", "title")
128+
self.assertTrue("86,400 seconds per day" in title)
129+
self.click('link=Blag')
128130
self.assert_text('The blag of the webcomic', 'h2')
129131
self.update_text('input#s', 'Robots!\n')
130132
self.assert_text('Hooray robots!', '#content')

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
theme: jekyll-theme-cayman
22
title: SeleniumBase
3-
description: Test Automation Framework
3+
description: Automated Web-UI Testing Framework

examples/my_first_test.py

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ def test_basic(self):
77
self.open('http://xkcd.com/353/') # Navigate to the web page
88
self.assert_element('img[alt="Python"]') # Assert element on page
99
self.click('a[rel="license"]') # Click element on page
10-
text = self.get_text("div center") # Grab text from page element
11-
self.assertTrue("reuse any of my drawings" in text)
12-
self.open('http://xkcd.com/1481/')
13-
title = self.get_attribute('#comic img', 'title') # Grab an attribute
14-
self.assertTrue('connections to the server' in title)
15-
self.click_link_text('Blag') # Click on link with the text
16-
self.assert_text('The blag of the webcomic', 'h2') # Assert text in h2
10+
self.assert_text('free to copy', 'div center') # Assert text on page
11+
self.open("http://xkcd.com/1481/")
12+
title = self.get_attribute("#comic img", "title") # Grab an attribute
13+
self.assertTrue("86,400 seconds per day" in title)
14+
self.click('link=Blag') # Click on link with the text
15+
self.assert_text('The blag of the webcomic', 'h2')
1716
self.update_text('input#s', 'Robots!\n') # Fill in field with the text
1817
self.assert_text('Hooray robots!', '#content')
1918
self.open('http://xkcd.com/1319/')
@@ -26,33 +25,25 @@ def test_basic(self):
2625
# **** NOTES / USEFUL INFO ****
2726
#
2827
# 1. By default, CSS Selectors are used to identify elements.
29-
# You can use other identification options like PARTIAL_LINK_TEXT:
28+
# Other options include: "LINK_TEXT", "PARTIAL_LINK_TEXT", "NAME",
29+
# "CLASS_NAME", and "ID", but most of those can be expressed as CSS.
30+
# Here's an example of changing the "by":
3031
# [
3132
# from selenium.webdriver.common.by import By
3233
# ...
3334
# self.click('Next', by=By.PARTIAL_LINK_TEXT)
3435
# ]
35-
# For the full list of `By` options, type ``dir(By)`` into a python
36-
# command prompt after importing it (or in ipdb debugger mode). Ex:
37-
# {
38-
# >>> dir(By)
39-
# ['CLASS_NAME', 'CSS_SELECTOR', 'ID', 'LINK_TEXT', 'NAME', ...
40-
# }
4136
# XPath is used by default if the arg starts with "/", "./", or "(":
4237
# [
4338
# self.click('/html/body/div[3]/div[4]/p[2]/a')
4439
# ]
45-
# But if you want XPath-clicking to be more clear in the code, use:
46-
# [
47-
# self.click_xpath('/html/body/div[3]/div[4]/p[2]/a')
48-
# ]
4940
#
5041
# If you're completely new to CSS selectors, right-click on a
51-
# web page and select "Inspect Element" to see the CSS in the html.
42+
# web page and select "Inspect" to see the CSS in the html.
5243
#
5344
# 2. Most methods have the optional `timeout` argument. Ex:
5445
# [
55-
# self.get_text('center', timeout=15)
46+
# self.get_text('div center', timeout=15)
5647
# ]
5748
# The `timeout` argument tells the method how many seconds to wait
5849
# for an element to appear before raising an exception. This is
@@ -62,33 +53,28 @@ def test_basic(self):
6253
#
6354
# 3. There's usually more than one way to do the same thing. Ex:
6455
# [
65-
# header_text = self.get_text('header h2')
66-
# self.assertTrue('The blag of the webcomic' in header_text)
56+
# self.assert_text('free to copy', 'div center')
6757
# ]
68-
# Can be simplified to:
69-
# [
70-
# self.assert_text('The blag of the webcomic', 'header_text')
71-
# ]
72-
#
73-
# The following line:
58+
# Is the same as:
7459
# [
75-
# title = self.get_attribute('#comic img', 'title')
60+
# text = self.get_text("div center")
61+
# self.assertTrue("free to copy" in text)
7662
# ]
77-
# Can also be written as:
63+
# Or:
7864
# [
79-
# element = self.find_element('#comic img')
80-
# title = element.get_attribute('title')
65+
# text = self.find_element('div center').text
66+
# assert("free to copy" in text)
8167
# ]
8268
#
8369
# And the following line:
8470
# [
85-
# text = self.get_text("div center")
71+
# title = self.get_attribute("#comic img", "title")
8672
# ]
8773
# Can also be written as:
8874
# [
89-
# text = self.find_element('div center').text
75+
# element = self.find_element("#comic img")
76+
# title = element.get_attribute("title")
9077
# ]
91-
# ...and in many more ways!
9278
#
9379
# For backwards-compatibilty, some methods have multiple names.
9480
# Ex: wait_for_element_visible() is the same as find_element().

help_docs/install.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## ![http://seleniumbase.com](https://cdn2.hubspot.net/hubfs/100006/images/super_logo_tiny.png "SeleniumBase") SeleniumBase Installation
2+
3+
If you're installing SeleniumBase from a cloned copy on your machine, use:
4+
```
5+
pip install -r requirements.txt
6+
7+
python setup.py develop
8+
```
9+
10+
If you're installing SeleniumBase from the [Python Package Index](https://pypi.python.org/pypi/seleniumbase), use:
11+
```bash
12+
pip install seleniumbase
13+
```
14+
15+
If you're installing SeleniumBase directly from GitHub, use:
16+
```bash
17+
pip install -e git+https://github.com/seleniumbase/SeleniumBase.git@master#egg=seleniumbase
18+
```
19+
20+
(If you already have an older version installed, you may want to add ``--upgrade`` to your ``pip`` command to update existing Python packages. If you're not using a virtual environment, you may need to add ``--user`` to your ``pip`` command if you're getting errors during installation.)
21+
22+
(If you want to use Python 3.x instead of Python 2.7, use ``pip3`` in place of ``pip`` and ``python3`` in place of ``python``.)

help_docs/method_summary.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ self.switch_to_default_content()
254254

255255
self.save_screenshot(name, folder=None)
256256

257+
self.get_new_driver(browser=None, headless=None, servername=None, port=None,
258+
proxy_string=None)
259+
257260
########
258261

259262
self.delayed_assert_element(selector, by=By.CSS_SELECTOR,

help_docs/mysql_installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can use the [testcaserepository.sql](https://github.com/seleniumbase/Seleniu
3131

3232
If you were able to successfully install MySQL, you can now install the remaining MySQL requirements:
3333
```bash
34-
pip install -r server_requirements.txt
34+
pip install -r requirements.txt
3535
```
3636
(NOTE: This install uses Selenium 2.53.6 rather than the usual Selenium 3+ from the standard requirements file due to compatibility issues with running browser tests on headless server machines.)
3737

@@ -44,7 +44,7 @@ You'll want to update your [settings.py](https://github.com/seleniumbase/Seleniu
4444
Add the ``--with-db_reporting`` argument on the command line when you want tests to write to your MySQL database.
4545
Example:
4646
```bash
47-
nosetests my_first_test.py --with-selenium --with-db_reporting
47+
nosetests my_first_test.py --with-db_reporting
4848
```
4949

5050
#### Windows mysql-python troubleshooting:

help_docs/webdriver_installation.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33

44
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)**. On a Mac, ``/usr/local/bin`` is a good spot. On Windows, make sure you set the System Path under Environment Variables to include the location where you placed the driver files. You may want to download newer versions of drivers as they become available.
55

6-
* For Chrome, get [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) on your System Path.
6+
* For Chrome, get [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) on your System PATH.
77

8-
* For Firefox, get [Geckodriver](https://github.com/mozilla/geckodriver/releases) on your System Path.
8+
* For Firefox, get [Geckodriver](https://github.com/mozilla/geckodriver/releases) on your System PATH.
99

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

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

14-
* For PhantomJS headless browser automation, get [PhantomJS](http://phantomjs.org/download.html) on your System Path. (NOTE: PhantomJS is no longer officially supported by SeleniumHQ)
14+
* For PhantomJS headless browser automation, get [PhantomJS](http://phantomjs.org/download.html) on your System PATH. (NOTE: <i>PhantomJS is no longer officially supported by SeleniumHQ</i>)
1515

16-
Mac:
16+
(NOTE: <i>If you can't get a WebDriver on your system PATH, you'll need to edit ``requirements.txt`` and ``setup.py`` to use selenium==2.53.6 instead of selenium 3.x, which will limit you to running tests on [Firefox 46.x](https://ftp.mozilla.org/pub/firefox/releases/46.0.1/) & earlier.</i>)
17+
18+
**Mac**:
1719

1820
* On a Mac, you can install drivers more easily by using ``brew`` (aka ``homebrew``), but you have to install that first. [Brew installation instructions are here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/install_python_pip_git.md).
1921

@@ -23,15 +25,15 @@ brew install chromedriver
2325
brew install geckodriver
2426
```
2527

26-
(NOTE: If your existing version of chromedriver is less than 2.36, **upgrading is recommended!**)
28+
(NOTE: If your existing version of chromedriver is less than 2.37, **upgrading is required!**)
2729

2830
```bash
2931
brew upgrade chromedriver
3032

3133
brew upgrade geckodriver
3234
```
3335

34-
Linux:
36+
**Linux**:
3537

3638
```bash
3739
wget http://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip

integrations/node_js/my_first_test.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ def test_basic(self):
77
self.open('http://xkcd.com/353/')
88
self.assert_element('img[alt="Python"]')
99
self.click('a[rel="license"]')
10-
text = self.get_text("div center")
11-
self.assertTrue("reuse any of my drawings" in text)
12-
self.open('http://xkcd.com/1481/')
13-
title = self.get_attribute('#comic img', 'title')
14-
self.assertTrue('connections to the server' in title)
10+
self.assert_text('free to copy', 'div center')
11+
self.open("http://xkcd.com/1481/")
12+
title = self.get_attribute("#comic img", "title")
13+
self.assertTrue("86,400 seconds per day" in title)
1514
self.click('link=Blag')
1615
self.assert_text('The blag of the webcomic', 'h2')
1716
self.update_text('input#s', 'Robots!\n')

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
pip>=9.0.1
2-
setuptools>=38.5.2
1+
pip>=9.0.3
2+
setuptools>=39.0.1
33
ipython==5.5.0
44
selenium==3.8.1
55
nose==1.3.7
6-
pytest==3.4.2
6+
pytest==3.5.0
77
pytest-html==1.16.1
88
pytest-xdist==1.22.2
99
six==1.10.0
@@ -13,6 +13,6 @@ BeautifulSoup4==4.6.0
1313
unittest2==1.1.0
1414
chardet==3.0.4
1515
boto==2.48.0
16-
ipdb==0.10.2
16+
ipdb==0.11
1717
pyvirtualdisplay==0.2.1
1818
-e .

0 commit comments

Comments
 (0)