Skip to content

Commit c8910de

Browse files
authored
Merge pull request #376 from seleniumbase/new-methods-scripts-and-updates
New methods, scripts, updates, and tests
2 parents b5f743b + 0f89047 commit c8910de

File tree

23 files changed

+496
-204
lines changed

23 files changed

+496
-204
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_3.png" title="SeleniumBase" height="45">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
1+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_3.png" title="SeleniumBase" align="center" height="45">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

33
[<img src="https://img.shields.io/github/release/seleniumbase/SeleniumBase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/releases) [<img src="https://dev.azure.com/seleniumbase/seleniumbase/_apis/build/status/seleniumbase.SeleniumBase?branchName=master" alt=" " />](https://dev.azure.com/seleniumbase/seleniumbase/_build/latest?definitionId=1&branchName=master) [<img src="https://travis-ci.org/seleniumbase/SeleniumBase.svg?branch=master" alt=" " />](https://travis-ci.org/seleniumbase/SeleniumBase) [<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt=" " />](https://gitter.im/seleniumbase/SeleniumBase) [<img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE) [<img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg" alt=" " />](https://github.com/seleniumbase/SeleniumBase/stargazers)<br />
44

@@ -23,9 +23,9 @@ With Python installed and on your System PATH, you can get the latest ``pip`` wi
2323
python -m easy_install -U pip
2424
```
2525

26-
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Setup a Virtual Environment: (Optional)
26+
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Setup a Python Virtual Env:
2727

28-
You may want to use a **Python Virtual Environment** to isolate Python dependencies between projects. Instructions on creating one can be found **[here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md)**. (<i>Learn more about virtual environments on the official site **[here](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)**.</i>)
28+
It is **recommended** to use a **Python Virtual Environment** to isolate Python dependencies between projects. Instructions on creating one can be found **[here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md)**. (<i>Learn more about virtual environments on the **[official site](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)**.</i>)
2929

3030
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Install ``seleniumbase``: [<img src="https://img.shields.io/badge/pypi-seleniumbase-22AAEE.svg" alt=" " />](https://pypi.python.org/pypi/seleniumbase)
3131
```bash

examples/ReadMe.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,13 @@ Run a test that demonstrates how to upload a file to a website:
7070
pytest upload_file_test.py
7171
```
7272

73-
For more advanced run commands, such as using a proxy server, see [../help_docs/customizing_test_runs.md](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md)
73+
For more advanced run commands, such as using a proxy server, see [../help_docs/customizing_test_runs.md](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md)
7474

7575
--------
7676

77-
To makes things easier, here's a simple GUI program that allows you to kick off a few example scripts by pressing a button:
77+
To makes things easier, here's a simple GUI program that allows you to run a few example scripts by pressing a button:
7878

7979
```bash
8080
python gui_test_runner.py
8181
```
82-
83-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/The_GUI_Runner.png" title="GUI Test Runner" height="400">
84-
85-
(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.)
82+
<img src="https://cdn2.hubspot.net/hubfs/100006/images/gui_test_runner_py.png" title="GUI Test Runner">

examples/decryption_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
This test demonstrates the use of encryption/decryption.
3+
(Technically, obfuscation/unobfuscation.)
4+
"""
5+
6+
from seleniumbase import BaseCase
7+
from seleniumbase import encryption
8+
9+
10+
class MyTestClass(BaseCase):
11+
12+
def test_rate_limited_printing(self):
13+
self.open("https://www.saucedemo.com/")
14+
self.update_text("#user-name", "standard_user")
15+
16+
encrypted_password = "$^*ENCRYPT=S3BDTAdCWzMmKEY8Gjg=?&#$"
17+
print("Encrypted Password = %s" % encrypted_password)
18+
password = encryption.decrypt(encrypted_password)
19+
print("Password = %s" % password)
20+
self.update_text("#password", password)
21+
22+
self.click('input[type="submit"]')
23+
self.assert_text("Products", "div.product_label")
24+
self.assert_element("#inventory_container")

examples/gui_test_runner.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,74 @@
11
'''
22
GUI TEST RUNNER
33
Run by Typing: "python gui_test_runner.py"
4+
(Use Python 3 - There are GUI issues when using Python 2)
45
'''
56

6-
try:
7-
# Python 2
8-
from Tkinter import Tk, Frame, Button, Label
9-
except Exception:
10-
# Python 3
11-
from tkinter import Tk, Frame, Button, Label
127
import os
8+
import sys
9+
if sys.version_info[0] >= 3:
10+
from tkinter import Tk, Frame, Button, Label
11+
else:
12+
from Tkinter import Tk, Frame, Button, Label
1313

1414

1515
class App:
1616

1717
def __init__(self, master):
18-
frame = Frame()
18+
frame = Frame(master)
1919
frame.pack()
20-
root.title("Select Test Job To Run")
2120
self.label = Label(root, width=40).pack()
2221
self.title = Label(frame, text="", fg="black").pack()
2322
self.title1 = Label(
24-
frame, text="Basic Test Run in Chrome:", fg="blue").pack()
23+
frame, text=("Run a Test in Chrome:"), fg="blue").pack()
2524
self.run1 = Button(
2625
frame, command=self.run_1,
27-
text=("pytest my_first_test.py"
28-
" --browser=chrome")).pack()
26+
text=("pytest my_first_test.py --browser=chrome"),
27+
fg="green").pack()
2928
self.title2 = Label(
30-
frame, text="Basic Test Run in Firefox:", fg="blue").pack()
29+
frame, text=("Run a Test in Firefox:"), fg="blue").pack()
3130
self.run2 = Button(
3231
frame, command=self.run_2,
33-
text=("pytest my_first_test.py"
34-
" --browser=firefox")).pack()
32+
text=("pytest my_first_test.py --browser=firefox"),
33+
fg="green").pack()
3534
self.title3 = Label(
36-
frame, text="Basic Test Run in Demo Mode:", fg="blue").pack()
35+
frame, text="Run a Test with Demo Mode:", fg="blue").pack()
3736
self.run3 = Button(
3837
frame, command=self.run_3,
39-
text=("pytest my_first_test.py"
40-
" --browser=chrome --demo_mode")).pack()
38+
text=("pytest my_first_test.py --browser=chrome --demo_mode"),
39+
fg="green").pack()
4140
self.title4 = Label(
4241
frame,
43-
text="Basic Failing Test Run with Screenshots:",
42+
text="Run a Parameterized Test:",
4443
fg="blue").pack()
4544
self.run4 = Button(
4645
frame, command=self.run_4,
47-
text=("nosetests test_fail.py"
48-
" --browser=chrome --demo_mode")).pack()
46+
text=("pytest parameterized_test.py --browser=chrome"),
47+
fg="green").pack()
4948
self.title5 = Label(
5049
frame,
51-
text="Basic Failing Test Suite Run with Test Report:",
50+
text="Run a Failing Test (automatic screenshots):",
5251
fg="blue").pack()
5352
self.run5 = Button(
5453
frame, command=self.run_5,
55-
text=("nosetests test_suite.py --report --show_report")).pack()
54+
text=("pytest test_fail.py --browser=chrome"),
55+
fg="red").pack()
5656
self.title6 = Label(
5757
frame,
58-
text="Basic Failing Test Run showing the Multiple-Checks feature:",
58+
text="Run a Failing Test Suite with a Test Report:",
5959
fg="blue").pack()
6060
self.run6 = Button(
6161
frame, command=self.run_6,
62-
text=("nosetests delayed_assert_test.py --browser=chrome")).pack()
62+
text=("pytest test_suite.py --browser=chrome --html=report.html"),
63+
fg="red").pack()
6364
self.title7 = Label(
6465
frame,
65-
text="Use MySQL DB Reporting: (See ReadMe.md for Setup Steps!)",
66+
text="Run a Failing Test with Delayed Asserts:",
6667
fg="blue").pack()
6768
self.run7 = Button(
6869
frame, command=self.run_7,
69-
text=("nosetests test_suite.py"
70-
" --browser=chrome --with-db_reporting")).pack()
70+
text=("pytest test_delayed_asserts.py --browser=chrome"),
71+
fg="red").pack()
7172
self.end_title = Label(frame, text="", fg="black").pack()
7273
self.quit = Button(frame, text="QUIT", command=frame.quit).pack()
7374

@@ -81,29 +82,28 @@ def run_2(self):
8182

8283
def run_3(self):
8384
os.system(
84-
'pytest my_first_test.py --demo_mode'
85-
' --browser=chrome')
85+
'pytest my_first_test.py --browser=chrome --demo_mode')
8686

8787
def run_4(self):
8888
os.system(
89-
'nosetests test_fail.py --browser=chrome --demo_mode')
89+
'pytest parameterized_test.py --browser=chrome')
9090

9191
def run_5(self):
9292
os.system(
93-
'nosetests test_suite.py --report --show_report')
93+
'pytest test_fail.py --browser=chrome')
9494

9595
def run_6(self):
9696
os.system(
97-
'nosetests delayed_assert_test.py --browser=chrome')
97+
'pytest test_suite.py --browser=chrome --html=report.html')
9898

9999
def run_7(self):
100100
os.system(
101-
'nosetests test_suite.py'
102-
' --browser=chrome --with-db_reporting')
101+
'pytest test_delayed_asserts.py --browser=chrome')
103102

104103

105104
if __name__ == "__main__":
106105
root = Tk()
107-
root.minsize(532, 444)
106+
root.title("Select Test Job To Run")
107+
root.minsize(500, 420)
108108
app = App(root)
109109
root.mainloop()

examples/raw_parameter_script.py

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,47 @@
2525
# Example run command: "python raw_parameter_script.py"
2626
from my_first_test import MyTestClass # (relative imports DON'T work)
2727

28-
b = MyTestClass("test_basic")
29-
b.browser = "chrome"
30-
b.headless = False
31-
b.headed = False
32-
b.start_page = None
33-
b.servername = "localhost"
34-
b.port = 4444
35-
b.data = None
36-
b.environment = "test"
37-
b.user_agent = None
38-
b.extension_zip = None
39-
b.extension_dir = None
40-
b.database_env = "test"
41-
b.log_path = "latest_logs/"
42-
b.archive_logs = False
43-
b.disable_csp = False
44-
b.enable_sync = False
45-
b.visual_baseline = False
46-
b.maximize_option = False
47-
b.save_screenshot_after_test = False
48-
b.timeout_multiplier = None
49-
b.pytest_html_report = None
50-
b.report_on = False
51-
b.with_db_reporting = False
52-
b.with_s3_logging = False
53-
b.js_checking_on = False
54-
b.is_pytest = False
55-
b.demo_mode = False
56-
b.demo_sleep = 1
57-
b.message_duration = 2
58-
b.settings_file = None
59-
b.user_data_dir = None
60-
b.proxy_string = None
61-
b.ad_block_on = False
62-
b.highlights = None
63-
b.check_js = False
64-
b.cap_file = None
28+
sb = MyTestClass("test_basic")
29+
sb.browser = "chrome"
30+
sb.headless = False
31+
sb.headed = False
32+
sb.start_page = None
33+
sb.servername = "localhost"
34+
sb.port = 4444
35+
sb.data = None
36+
sb.environment = "test"
37+
sb.user_agent = None
38+
sb.extension_zip = None
39+
sb.extension_dir = None
40+
sb.database_env = "test"
41+
sb.log_path = "latest_logs/"
42+
sb.archive_logs = False
43+
sb.disable_csp = False
44+
sb.enable_sync = False
45+
sb.visual_baseline = False
46+
sb.maximize_option = False
47+
sb.save_screenshot_after_test = False
48+
sb.timeout_multiplier = None
49+
sb.pytest_html_report = None
50+
sb.report_on = False
51+
sb.with_db_reporting = False
52+
sb.with_s3_logging = False
53+
sb.js_checking_on = False
54+
sb.is_pytest = False
55+
sb.demo_mode = False
56+
sb.demo_sleep = 1
57+
sb.message_duration = 2
58+
sb.settings_file = None
59+
sb.user_data_dir = None
60+
sb.proxy_string = None
61+
sb.ad_block_on = False
62+
sb.highlights = None
63+
sb.check_js = False
64+
sb.cap_file = None
6565

66-
b.setUp()
66+
sb.setUp()
6767
try:
68-
b.test_basic()
68+
sb.test_basic()
6969
finally:
70-
b.tearDown()
71-
del b
70+
sb.tearDown()
71+
del sb
File renamed without changes.

examples/tour_examples/ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## SeleniumBase Website Tours
22

3-
SeleniumBase Tours utilize your choice of 4 different JavaScript libraries for prototyping tours, demos, walkthroughs, and onboarding experiences on any website: **[Shepherd](https://shipshapecode.github.io/shepherd/docs/welcome/)**, **[Bootstrap Tour](http://bootstraptour.com/)**, **[IntroJS](https://introjs.com/)**, and **[Hopscotch](http://linkedin.github.io/hopscotch/)**. Choose your favorite one to use!
3+
SeleniumBase Tours utilize your choice of 4 different JavaScript libraries for prototyping walkthroughs, onboarding experiences, and digital adoption solutions on any website:<br>**[Shepherd](https://shipshapecode.github.io/shepherd/docs/welcome/)**, **[Bootstrap Tour](http://bootstraptour.com/)**, **[IntroJS](https://introjs.com/)**, and **[Hopscotch](http://linkedin.github.io/hopscotch/)**.<br>Choose your favorite one to use!
44

55
Example tour:
66

@@ -9,7 +9,7 @@ cd examples/tour_examples
99
pytest google_tour.py
1010
```
1111

12-
<img src="https://cdn2.hubspot.net/hubfs/100006/google_tour_3.gif" title="SeleniumBase Tour of Google" height="260"><br>
12+
<img src="https://cdn2.hubspot.net/hubfs/100006/google_tour_3.gif" title="SeleniumBase Tour of Google"><br>
1313

1414

1515
### Creating a new tour:

0 commit comments

Comments
 (0)