Skip to content

Commit 684c977

Browse files
authored
Merge pull request #136 from seleniumbase/simplify-all-the-things
Simplify all the things
2 parents 8ab15e0 + 56633fa commit 684c977

26 files changed

+272
-281
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
(<i>Demo of [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) testing [xkcd.com](http://xkcd.com/353/)</i>)
1010

1111
### ![http://seleniumbase.com](https://cdn2.hubspot.net/hubfs/100006/images/super_logo_tiny.png "SeleniumBase") **Features**:
12-
* [Python libraries](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures) to help you build reliable [WebDriver scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py). (<i>Python 2.7 or 3.3+</i>)
12+
* [Python libraries](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures) to help you build reliable [WebDriver scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py). (<i>Python 2.7 or 3.4+</i>)
1313
* [Command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/command_line.md) and a global [config file](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) to customize runs.
1414
* [Plugins](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/plugins) for logging [data & screenshots](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/example_logs).
1515
* Works with [Selenium Grid](https://github.com/seleniumbase/SeleniumBase/tree/master/integrations/selenium_grid), [MySQL](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/core/testcase_manager.py), [Docker](https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/docker/ReadMe.md), [NodeJS](https://github.com/seleniumbase/SeleniumBase/tree/master/integrations/node_js), [Google Cloud](https://github.com/seleniumbase/SeleniumBase/tree/master/integrations/google_cloud/ReadMe.md), and [AWS](#amazon_section).
@@ -95,25 +95,25 @@ class MyTestClass(BaseCase):
9595
```bash
9696
cd examples/
9797

98-
pytest my_first_test.py --with-selenium --browser=chrome
98+
pytest my_first_test.py --browser=chrome
9999

100-
nosetests my_first_test.py --with-selenium --browser=firefox
100+
nosetests my_first_test.py --browser=firefox
101101

102-
nosetests my_first_test.py --with-selenium --browser=phantomjs
102+
nosetests my_first_test.py --browser=phantomjs
103103
```
104104
(<i>If no browser is specified, Chrome is used by default.</i>)
105105

106106
<a id="seleniumbase_demo_mode"></a>
107107
If the example test is moving too fast for your eyes to see what's going on, you can run it in **Demo Mode** by adding ``--demo_mode`` on the command line, which pauses the browser briefly between actions, and highlights page elements being acted on:
108108

109109
```bash
110-
pytest my_first_test.py --with-selenium --browser=chrome --demo_mode
110+
pytest my_first_test.py --browser=chrome --demo_mode
111111
```
112112

113113
You can override the default wait time by either updating [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) or by using ``--demo_sleep={NUM}`` when using Demo Mode. (NOTE: If you use ``--demo_sleep={NUM}`` without using ``--demo_mode``, nothing will happen.)
114114

115115
```bash
116-
nosetests my_first_test.py --with-selenium --browser=chrome --demo_mode --demo_sleep=1.2
116+
nosetests my_first_test.py --browser=chrome --demo_mode --demo_sleep=1.2
117117
```
118118

119119
You can also use the following in your scripts to slow down the tests:
@@ -130,7 +130,7 @@ You may also want to have your test sleep in other situations where you need to
130130
If you need to debug things on the fly (in case of errors), use this:
131131

132132
```bash
133-
nosetests my_first_test.py --browser=chrome --with-selenium --pdb --pdb-failures -s
133+
nosetests my_first_test.py --browser=chrome --pdb --pdb-failures -s
134134
```
135135

136136
The above code (with --pdb) will leave your browser window open in case there's a failure, which is possible if the web pages from the example change the data that's displayed on the page. (ipdb commands: 'c', 's', 'n' => continue, step, next). You may need the ``-s`` in order to see all console output.
@@ -179,7 +179,7 @@ pytest my_test_suite.py --html=report.html
179179
The ``--report`` option gives you a fancy report after your test suite completes. (Requires ``--with-testing_base`` to also be set when ``--report`` is used because it's part of that plugin.)
180180

181181
```bash
182-
nosetests my_test_suite.py --with-selenium --with-testing_base --report
182+
nosetests my_test_suite.py --with-testing_base --report
183183
```
184184
![](https://cdn2.hubspot.net/hubfs/100006/images/Test_Report_2.png "Example Nosetest Report")
185185

@@ -208,7 +208,7 @@ Here are some things you can do to setup a production environment for your testi
208208

209209
Here's an example of running tests with additional features enabled:
210210
```bash
211-
nosetests [YOUR_TEST_FILE].py --browser=chrome --with-selenium --with-testing_base --with-db_reporting --with-s3_logging -s
211+
nosetests [YOUR_TEST_FILE].py --browser=chrome --with-testing_base --with-db_reporting --with-s3_logging -s
212212
```
213213
(NOTE: If you haven't configured your MySQL or S3 connections in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), don't use ``--with-db_reporting`` or ``--with-s3_logging``.)
214214

@@ -242,7 +242,7 @@ class MyTestClass(BaseCase):
242242
Now run it:
243243

244244
```bash
245-
nosetests test_fail.py --browser=chrome --with-selenium --with-testing_base
245+
nosetests test_fail.py --browser=chrome --with-testing_base
246246
```
247247

248248
You'll notice that a logs folder, "latest_logs", was created to hold information about the failing test, and screenshots. Take a look at what you get. Remember, this data can be saved in your MySQL DB and in S3 if you include the necessary plugins in your run command (and if you set up the neccessary connections properly). For future test runs, past test results will get stored in the archived_logs folder if you have ARCHIVE_EXISTING_LOGS set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py).

examples/ReadMe.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ python gui_test_runner.py
1212

1313
(NOTE: You can interchange ``nosetests`` with ``pytest`` in most of these examples.)
1414

15-
![](http://cdn2.hubspot.net/hubfs/100006/images/GUI_Test_Runner_5.png "GUI Test Runner")
15+
![](https://cdn2.hubspot.net/hubfs/100006/images/GUI_Test_Runner_7.png "GUI Test Runner")
1616

1717
If you run scripts with logging enabled, (using ``--with-testing_base``), you’ll see two folders appear: “latest_logs” and “archived_logs”. The “latest_logs” folder will contain log files from the most recent test run, but logs will only be created if the test run is failing. Afterwards, logs from the “latest_logs” folder will get pushed to the “archived_logs” folder if you have have the ``ARCHIVE_EXISTING_LOGS`` feature enabled in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py).
1818

@@ -40,17 +40,17 @@ pytest my_first_test.py --browser=chrome --demo_mode
4040

4141
Run the example test suite in Chrome and generate an html report: (nosetests-only)
4242
```bash
43-
nosetests my_test_suite.py --with-selenium --browser=chrome --with-testing_base --report
43+
nosetests my_test_suite.py --browser=chrome --with-testing_base --report
4444
```
4545

4646
Run the example test suite in Firefox and generate an html report: (nosetests-only)
4747
```bash
48-
nosetests my_test_suite.py --with-selenium --browser=firefox --with-testing_base --report
48+
nosetests my_test_suite.py --browser=firefox --with-testing_base --report
4949
```
5050

5151
Run the example test suite in PhantomJS and generate an html report: (nosetests-only)
5252
```bash
53-
nosetests my_test_suite.py --with-selenium --browser=phantomjs --with-testing_base --report
53+
nosetests my_test_suite.py --browser=phantomjs --with-testing_base --report
5454
```
5555

5656
Run a test with configuration specifed by a config file:
@@ -65,12 +65,12 @@ nosetests rate_limiting_test.py
6565

6666
Run a failing test with pdb mode enabled: (If a test failure occurs, test enters pdb mode)
6767
```bash
68-
nosetests test_fail.py --browser=chrome --with-selenium --pdb --pdb-failures
68+
nosetests test_fail.py --browser=chrome --pdb --pdb-failures
6969
```
7070

7171
Run a failing test with logging:
7272
```bash
73-
pytest test_fail.py --browser=chrome --with-testing_base --with-basic_test_info --with-page_source --with-screen_shots
73+
pytest test_fail.py --browser=chrome --with-testing_base
7474
```
7575

7676
(NOTE: If you see any ``*.pyc`` files appear as you run tests, that's perfectly normal. Compiled bytecode is a natural result of running Python code.)

examples/boilerplates/samples/google_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ def test_google_dot_com(self):
1414
self.assert_element(HomePage.feeling_lucky_button)
1515
self.update_text(HomePage.search_box, "github\n")
1616
self.assert_text("github.com", ResultsPage.search_results)
17-
self.assert_element(ResultsPage.google_logo)
1817
self.click_link_text("Images")
1918
self.assert_element('img[alt="Image result for github"]')

examples/gui_test_runner.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,92 +24,91 @@ def __init__(self, master):
2424
frame, text="Basic Test Run in Chrome:", fg="blue").pack()
2525
self.run1 = Button(
2626
frame, command=self.run_1,
27-
text=("pytest my_first_test.py --with-selenium"
27+
text=("pytest my_first_test.py"
2828
" --browser=chrome")).pack()
2929
self.title2 = Label(
3030
frame, text="Basic Test Run in Firefox:", fg="blue").pack()
3131
self.run2 = Button(
3232
frame, command=self.run_2,
3333
text=("pytest my_first_test.py"
34-
" --with-selenium --browser=firefox")).pack()
34+
" --browser=firefox")).pack()
3535
self.title3 = Label(
3636
frame, text="Basic Test Run in Demo Mode:", fg="blue").pack()
3737
self.run3 = Button(
3838
frame, command=self.run_3,
39-
text=("nosetests my_first_test.py"
40-
" --with-selenium --browser=chrome --demo_mode")).pack()
39+
text=("pytest my_first_test.py"
40+
" --browser=chrome --demo_mode")).pack()
4141
self.title4 = Label(
4242
frame,
4343
text="Basic Failing Test Run with Screenshots:",
4444
fg="blue").pack()
4545
self.run4 = Button(
4646
frame, command=self.run_4,
47-
text=("nosetests test_fail.py --with-selenium --browser=chrome"
47+
text=("nosetests test_fail.py --browser=chrome"
4848
" --with-testing_base --demo_mode")).pack()
4949
self.title5 = Label(
5050
frame,
5151
text="Basic Failing Test Suite Run with Test Report:",
5252
fg="blue").pack()
5353
self.run5 = Button(
5454
frame, command=self.run_5,
55-
text=("nosetests my_test_suite.py --with-selenium"
56-
" --browser=chrome --with-testing_base "
57-
"--report --show_report")).pack()
55+
text=("nosetests my_test_suite.py --with-testing_base"
56+
" --report --show_report")).pack()
5857
self.title6 = Label(
5958
frame,
6059
text="Basic Failing Test Run showing the Multiple-Checks feature:",
6160
fg="blue").pack()
6261
self.run6 = Button(
6362
frame, command=self.run_6,
6463
text=("nosetests non_terminating_checks_test.py"
65-
" --browser=chrome --with-selenium")).pack()
64+
" --browser=chrome")).pack()
6665
self.title7 = Label(
6766
frame,
68-
text="MySQL DB Reporting Tests: (See ReadMe.md for Setup Steps!)",
67+
text="Use MySQL DB Reporting: (See ReadMe.md for Setup Steps!)",
6968
fg="blue").pack()
7069
self.run7 = Button(
7170
frame, command=self.run_7,
72-
text=("nosetests my_test_suite.py --with-selenium"
71+
text=("nosetests my_test_suite.py"
7372
" --browser=chrome --with-db_reporting")).pack()
7473
self.end_title = Label(frame, text="", fg="black").pack()
7574
self.quit = Button(frame, text="QUIT", command=frame.quit).pack()
7675

7776
def run_1(self):
7877
os.system(
79-
'pytest my_first_test.py --with-selenium --browser=chrome')
78+
'pytest my_first_test.py --browser=chrome')
8079

8180
def run_2(self):
8281
os.system(
83-
'pytest my_first_test.py --with-selenium --browser=firefox')
82+
'pytest my_first_test.py --browser=firefox')
8483

8584
def run_3(self):
8685
os.system(
87-
'nosetests my_first_test.py --with-selenium --demo_mode'
86+
'pytest my_first_test.py --demo_mode'
8887
' --browser=chrome')
8988

9089
def run_4(self):
9190
os.system(
92-
'nosetests test_fail.py --with-selenium'
91+
'nosetests test_fail.py'
9392
' --browser=chrome --with-testing_base --demo_mode')
9493

9594
def run_5(self):
9695
os.system(
97-
'nosetests my_test_suite.py --with-selenium'
98-
' --browser=chrome --with-testing_base --report --show_report')
96+
'nosetests my_test_suite.py'
97+
' --with-testing_base --report --show_report')
9998

10099
def run_6(self):
101100
os.system(
102-
'nosetests non_terminating_checks_test.py --with-selenium'
101+
'nosetests non_terminating_checks_test.py'
103102
' --browser=chrome')
104103

105104
def run_7(self):
106105
os.system(
107-
'nosetests my_test_suite.py --with-selenium'
106+
'nosetests my_test_suite.py'
108107
' --browser=chrome --with-db_reporting')
109108

110109

111110
if __name__ == "__main__":
112111
root = Tk()
113-
root.minsize(700, 444)
112+
root.minsize(560, 444)
114113
app = App(root)
115114
root.mainloop()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nosetests my_first_test.py --browser=chrome --with-selenium --logging-level=INFO -s
1+
nosetests my_first_test.py --browser=chrome --logging-level=INFO -s
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nosetests my_first_test.py --browser=firefox --with-selenium --logging-level=INFO -s
1+
nosetests my_first_test.py --browser=firefox --logging-level=INFO -s
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nosetests test_fail.py --with-selenium --with-testing_base --with-basic_test_info --with-page_source --with-screen_shots
1+
nosetests test_fail.py --with-testing_base

integrations/google_cloud/ReadMe.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ sudo python server_setup.py develop
8484
![](http://cdn2.hubspot.net/hubfs/100006/images/gcp_bitnami.png "Linux SSH Terminal")
8585

8686
```bash
87-
py.test examples/my_first_test.py --with-selenium --headless --browser=chrome
87+
pytest examples/my_first_test.py --headless --browser=chrome
8888
```
8989

9090
#### Step 14. If you like nosetests better than pytest, that works too
9191

9292
```bash
93-
nosetests examples/my_first_test.py --with-selenium --headless --browser=chrome
93+
nosetests examples/my_first_test.py --headless --browser=chrome
9494
```
9595

9696
#### Step 15. You can also verify that the example test runs on Firefox
9797

9898
```bash
99-
nosetests examples/my_first_test.py --with-selenium --headless --browser=firefox
99+
nosetests examples/my_first_test.py --headless --browser=firefox
100100
```
101101

102102
#### Step 16. Login to Jenkins
@@ -119,7 +119,7 @@ nosetests examples/my_first_test.py --with-selenium --headless --browser=firefox
119119
* Under "Build", click the "Add build step" dropdown and then select "Execute shell".
120120
* For the "Command", put:
121121
```bash
122-
nosetests examples/my_first_test.py --with-selenium --headless --browser=chrome
122+
nosetests examples/my_first_test.py --headless --browser=chrome
123123
```
124124
* Click "Save" when you're done.
125125

@@ -184,7 +184,7 @@ sudo python setup.py install
184184
* For the "Execute shell", use the following as your updated "Command":
185185

186186
```bash
187-
nosetests examples/my_test_suite.py --with-selenium --headless --browser=chrome --with-db_reporting --with-testing_base
187+
nosetests examples/my_test_suite.py --headless --browser=chrome --with-db_reporting --with-testing_base
188188
```
189189

190190
* Click "Save" when you're done.

integrations/selenium_grid/ReadMe.md

100644100755
File mode changed.

integrations/selenium_grid/download_selenium.py

100644100755
Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
1-
""" Download the selenium server jar file """
1+
""" Downloads the Selenium Server JAR file and renames it. """
22

33
import os
4-
from seleniumbase.core import selenium_launcher
4+
import sys
5+
import urllib
56

6-
if not selenium_launcher.is_available_locally():
7-
selenium_launcher.download_selenium()
7+
SELENIUM_JAR = ("http://selenium-release.storage.googleapis.com"
8+
"/2.53/selenium-server-standalone-2.53.0.jar")
9+
JAR_FILE = "selenium-server-standalone-2.53.0.jar"
10+
try:
11+
import selenium
12+
if selenium.__version__[0] == '3':
13+
SELENIUM_JAR = ("http://selenium-release.storage.googleapis.com"
14+
"/3.8/selenium-server-standalone-3.8.1.jar")
15+
JAR_FILE = "selenium-server-standalone-3.8.1.jar"
16+
except Exception:
17+
pass
818

9-
for filename in os.listdir("."):
10-
if filename.startswith("selenium-server-standalone-"):
11-
os.rename(filename, "selenium-server-standalone.jar")
19+
RENAMED_JAR_FILE = "selenium-server-standalone.jar"
20+
21+
22+
def download_selenium():
23+
"""
24+
Downloads the Selenium Server JAR file from its
25+
online location and stores it locally.
26+
"""
27+
try:
28+
local_file = open(JAR_FILE, 'wb')
29+
remote_file = urllib.urlopen(SELENIUM_JAR)
30+
print('Downloading Selenium Server JAR File...\n')
31+
local_file.write(remote_file.read())
32+
local_file.close()
33+
remote_file.close()
34+
print('Download Complete!\n')
35+
except Exception:
36+
raise Exception("Error downloading the Selenium Server JAR file.\n"
37+
"Details: %s" % sys.exc_info()[1])
38+
39+
40+
def is_available_locally():
41+
return os.path.isfile(RENAMED_JAR_FILE)
42+
43+
44+
if not is_available_locally():
45+
download_selenium()
46+
for filename in os.listdir("."):
47+
if filename.startswith("selenium-server-standalone-"):
48+
os.rename(filename, RENAMED_JAR_FILE)

integrations/selenium_grid/grid-node

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fi
2121
################################################################################
2222

2323
WEBDRIVER_SERVER_JAR=./selenium-server-standalone.jar
24-
WEBDRIVER_NODE_PARAMS="-role webdriver -hubHost 127.0.0.1 -hubPort 4444 -host 127.0.0.1 -browserName=firefox"
24+
WEBDRIVER_NODE_PARAMS="-role webdriver -hubHost 127.0.0.1 -hubPort 4444 -host 127.0.0.1 -browser browserName=firefox,maxInstances=5,version=ANY,platform=ANY -browser browserName=chrome,maxInstances=5,version=ANY,platform=ANY"
2525
WEBDRIVER_NODE_PIDFILE="/tmp/webdriver_node.pid"
2626

2727
if [ ! -f $WEBDRIVER_SERVER_JAR ]; then
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cd c:\
2+
java -jar selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register -browser browserName=chrome,maxInstances=5,version=ANY,platform=ANY -browser browserName=firefox,maxInstances=5,version=ANY,platform=ANY -browser browserName="internet explorer",maxInstances=1,version=ANY,platform=ANY
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
java -jar selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register -browser browserName=chrome,maxInstances=5,version=ANY,platform=ANY -browser browserName=firefox,maxInstances=5,version=ANY,platform=ANY

integrations/selenium_grid/selenium_server_config_example.cfg

100644100755
File mode changed.

integrations/selenium_grid/start-selenium-node.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cd c:\
2+
java -jar selenium-server-standalone.jar -role hub

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pip>=9.0.1
2-
setuptools>=38.2.4
2+
setuptools>=38.5.1
33
ipython==5.4.1
44
selenium==3.8.0
55
nose==1.3.7

seleniumbase/config/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
to be True since it's part of wait_for_ready_state_complete().
7171
'''
7272
# Called after each wait_for_ready_state_complete()
73-
WAIT_FOR_ANGULARJS = False
73+
WAIT_FOR_ANGULARJS = True
7474

7575
# Option to start Chrome in full screen mode by default
7676
START_CHROME_IN_FULL_SCREEN_MODE = False

0 commit comments

Comments
 (0)