Merge pull request #840 from seleniumbase/charts-pies-traffic-and-refactoring

Updates for ChartMaker, Traffic-generator, refactoring, and more
This commit is contained in:
Michael Mintz 2021-03-14 20:44:24 -04:00 committed by GitHub
commit 92385098fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 253 additions and 101 deletions

View File

@ -6,21 +6,22 @@
<link rel="icon" href="https://seleniumbase.io/img/logo6.png" />
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/">
<img src="https://seleniumbase.io/img/sb_logo_10.png" alt="SeleniumBase" title="SeleniumBase" width="280" /></a></p>
<img src="https://seleniumbase.io/cdn/img/sb_logo_gs.png" alt="SeleniumBase" title="SeleniumBase" width="500" /></a></p>
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/releases">
<img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=2277EE" alt="Latest Release on GitHub" /></a> <a href="https://pypi.python.org/pypi/seleniumbase">
<img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=22AAEE" alt="Latest Release on PyPI" /></a></p>
<p align="center">
<b>Build fast, reliable, end-to-end tests.</b>
<b>End-to-end testing for the next generation.</b>
</p>
<!-- View on GitHub -->
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/releases">
<img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=2277EE" alt="Latest Release on GitHub" /></a> <a href="https://pypi.python.org/pypi/seleniumbase">
<img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=22AAEE" alt="Latest Release on PyPI" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/actions">
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/actions">
<img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg" alt="SeleniumBase GitHub Actions" /></a> <a href="https://dev.azure.com/seleniumbase/seleniumbase/_build/latest?definitionId=1&branchName=master"> <img src="https://dev.azure.com/seleniumbase/seleniumbase/_apis/build/status/seleniumbase.SeleniumBase?branchName=master" alt="SeleniumBase Azure Pipelines" /></a> <a href="https://gitter.im/seleniumbase/SeleniumBase">
<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt="SeleniumBase" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/stargazers"><img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg?color=19A57B" title="Stargazers" /></a> <a href="https://seleniumbase.io">
<img src="https://img.shields.io/badge/docs-%20seleniumbase.io-22BBAA.svg" alt="SeleniumBase.io Docs" /></a></p>
<p>
SeleniumBase is a Python framework for web automation, end-to-end testing, and more.
SeleniumBase is a Python framework for fast and reliable web automation and testing.
Tests are run with "pytest". Browsers are controlled by WebDriver.
</p>
@ -50,9 +51,8 @@ Tests are run with "pytest". Browsers are controlled by WebDriver.
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/master_qa/ReadMe.md">🛂 MasterQA</a>
</p>
✅ Easy setup. Can run tests on any cloud.<br />
✅ Uses [Python APIs](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md) for web automation.<br />
✅ Can generate [test reports / dashboards](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).<br />
✅ Fast setup: All you need is [Python](https://www.python.org/downloads/)! 🐍<br />
✅ Includes [reporting & dashboard tools](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).<br />
--------

View File

@ -150,13 +150,16 @@ self.create_pie_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on
a web page, you no longer need to re-import the libraries
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```
@ -170,13 +173,16 @@ self.create_bar_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on
a web page, you no longer need to re-import the libraries
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```
@ -190,13 +196,16 @@ self.create_column_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on
a web page, you no longer need to re-import the libraries
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```
@ -210,14 +219,17 @@ self.create_line_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
zero - If True, the y-axis always starts at 0. (Default: False).
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on
a web page, you no longer need to re-import the libraries
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```
@ -231,7 +243,8 @@ self.create_area_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
zero - If True, the y-axis always starts at 0. (Default: False).
libs - The option to include Chart libraries (JS and CSS files).
@ -239,6 +252,8 @@ self.create_area_chart(
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```

View File

@ -1,7 +1,7 @@
from seleniumbase import BaseCase
class MyChartMakerClass(BaseCase):
class ChartMakerPresentation(BaseCase):
def test_chart_maker_presentation(self):
self.create_presentation(theme="sky", transition="zoom")
@ -12,13 +12,13 @@ class MyChartMakerClass(BaseCase):
self.add_data_point("Failed", 1, color="#f1888f")
self.add_slide("<p>Pie Chart</p>" + self.extract_chart())
self.create_bar_chart(title="Language", libs=False)
self.create_bar_chart(title="Language", libs=False, legend=False)
self.add_data_point("Python", 33, color="Orange")
self.add_data_point("JavaScript", 27, color="Teal")
self.add_data_point("HTML + CSS", 21, color="Purple")
self.add_slide("<p>Bar Chart</p>" + self.extract_chart())
self.create_column_chart(title="Colors", libs=False)
self.create_column_chart(title="Colors", libs=False, legend=False)
self.add_data_point("Red", 10, color="Red")
self.add_data_point("Green", 25, color="Green")
self.add_data_point("Blue", 15, color="Blue")

View File

@ -0,0 +1,45 @@
from seleniumbase import BaseCase
class PieCharts(BaseCase):
def test_pie_charts(self):
self.create_presentation(theme="serif", transition="convex")
self.create_pie_chart(labels=False)
self.add_data_point("Meringue Cream", 3, color="#f1eeea")
self.add_data_point("Lemon Filling", 3, color="#e9d655")
self.add_data_point("Graham Cracker Crust", 1, color="#9d5b34")
self.add_slide("<p>Lemon Meringue Pie</p>" + self.extract_chart())
self.create_pie_chart(labels=False)
self.add_data_point("Blueberries", 1, color="#5c81b7")
self.add_data_point("Blueberry Filling", 2, color="#12405e")
self.add_data_point("Golden Brown Crust", 1, color="#cd7b54")
self.add_slide("<p>Blueberry Pie</p>" + self.extract_chart())
self.create_pie_chart(labels=False)
self.add_data_point("Strawberries", 1, color="#ff282c")
self.add_data_point("Kiwis", 1, color="#a9c208")
self.add_data_point("Apricots", 1, color="#f47a14")
self.add_data_point("Raspberries", 1, color="#b10019")
self.add_data_point("Black Berries", 1, color="#44001e")
self.add_data_point("Blueberries", 1, color="#5c81b7")
self.add_data_point("Custard", 3, color="#eee896")
self.add_data_point("Golden Crust", 4, color="#dca422")
self.add_slide("<p>Fruit Tart Pie</p>" + self.extract_chart())
self.create_pie_chart(labels=False)
self.add_data_point("Apple Crust", 4, color="#b66327")
self.add_data_point("Apple Filling", 5, color="#c5903e")
self.add_data_point("Cinnamon", 1, color="#76210d")
self.add_data_point("Whipped Cream", 2, color="#f2f2f2")
self.add_slide("<p>Apple Pie</p>" + self.extract_chart())
self.create_pie_chart(labels=False)
self.add_data_point("Sponge Cake", 4, color="#e0d5a0")
self.add_data_point("Custard", 3, color="#eee896")
self.add_data_point("Chocolate", 1, color="#5c3625")
self.add_slide("<p>Boston Cream Pie</p>" + self.extract_chart())
self.begin_presentation(filename="pie_charts.html")

View File

@ -10,13 +10,13 @@ class MyChartMakerClass(BaseCase):
self.add_data_point("Failed", 1, color="#f1888f")
self.display_chart(filename="pie_chart.html", interval=2.5)
self.create_bar_chart(title="Bar Chart")
self.create_bar_chart(title="Bar Chart", legend=False)
self.add_data_point("Python", 33, color="Orange")
self.add_data_point("JavaScript", 27, color="Teal")
self.add_data_point("HTML + CSS", 21, color="Purple")
self.display_chart(filename="bar_chart.html", interval=2.5)
self.create_column_chart(title="Column Chart")
self.create_column_chart(title="Column Chart", legend=False)
self.add_data_point("Red", 10, color="Red")
self.add_data_point("Green", 25, color="Green")
self.add_data_point("Blue", 15, color="Blue")

View File

@ -150,13 +150,16 @@ self.create_pie_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on
a web page, you no longer need to re-import the libraries
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```
@ -170,13 +173,16 @@ self.create_bar_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on
a web page, you no longer need to re-import the libraries
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```
@ -190,13 +196,16 @@ self.create_column_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on
a web page, you no longer need to re-import the libraries
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```
@ -210,14 +219,17 @@ self.create_line_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
zero - If True, the y-axis always starts at 0. (Default: False).
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on
a web page, you no longer need to re-import the libraries
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```
@ -231,7 +243,8 @@ self.create_area_chart(
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
zero - If True, the y-axis always starts at 0. (Default: False).
libs - The option to include Chart libraries (JS and CSS files).
@ -239,6 +252,8 @@ self.create_area_chart(
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
```

View File

@ -405,19 +405,24 @@ self.begin_presentation(name=None, filename=None, show_notes=False, interval=0)
############
self.create_pie_chart(chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, libs=True)
data_name=None, unit=None, libs=True,
labels=True, legend=True)
self.create_bar_chart(chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, libs=True)
data_name=None, unit=None, libs=True,
labels=True, legend=True)
self.create_column_chart(chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, libs=True)
data_name=None, unit=None, libs=True,
labels=True, legend=True)
self.create_line_chart(chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, zero=False, libs=True)
data_name=None, unit=None, zero=False, libs=True,
labels=True, legend=True)
self.create_area_chart(chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, zero=False, libs=True)
data_name=None, unit=None, zero=False, libs=True,
labels=True, legend=True)
self.add_series_to_chart(data_name=None, chart_name=None)
@ -465,9 +470,9 @@ self.set_messenger_theme(theme="default", location="default",
############
self.generate_referral(start_page, destination_page)
self.generate_referral(start_page, destination_page, selector=None)
self.generate_traffic(start_page, destination_page, loops=1)
self.generate_traffic(start_page, destination_page, loops=1, selector=None)
self.generate_referral_chain(pages)

View File

@ -3,7 +3,7 @@ pip>=21.0.1;python_version>="3.6"
packaging>=20.9
setuptools>=44.1.1;python_version<"3.5"
setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"
setuptools>=54.1.1;python_version>="3.6"
setuptools>=54.1.2;python_version>="3.6"
setuptools-scm>=5.0.2
wheel>=0.36.2
attrs>=20.3.0
@ -33,7 +33,6 @@ py==1.10.0;python_version>="3.5"
pytest==4.6.11;python_version<"3.5"
pytest==6.1.2;python_version>="3.5" and python_version<"3.6"
pytest==6.2.2;python_version>="3.6"
pytest-cov==2.11.1
pytest-forked==1.3.0
pytest-html==1.22.1;python_version<"3.6"
pytest-html==2.0.1;python_version>="3.6"
@ -59,7 +58,7 @@ pygments==2.8.1;python_version>="3.5"
traitlets==4.3.3;python_version<"3.7"
traitlets==5.0.5;python_version>="3.7"
prompt-toolkit==1.0.18;python_version<"3.6"
prompt-toolkit==3.0.16;python_version>="3.6"
prompt-toolkit==3.0.17;python_version>="3.6"
ipython==5.10.0;python_version<"3.5"
ipython==6.5.0;python_version>="3.5" and python_version<"3.6"
ipython==7.16.1;python_version>="3.6" and python_version<"3.7"
@ -70,7 +69,6 @@ importlib-metadata==2.0.0;python_version<"3.6"
virtualenv>=20.4.2
pymysql==0.10.1;python_version<"3.6"
pymysql==1.0.2;python_version>="3.6"
coverage==5.5
brython==3.9.1
pyotp==2.6.0
boto==2.49.0
@ -80,13 +78,21 @@ Pillow==6.2.2;python_version<"3.5"
Pillow==7.2.0;python_version>="3.5" and python_version<"3.6"
Pillow==8.1.2;python_version>="3.6"
rich==9.13.0;python_version>="3.6" and python_version<"4.0"
flake8==3.7.9;python_version<"3.5"
flake8==3.8.4;python_version>="3.5"
pyflakes==2.1.1;python_version<"3.5"
pyflakes==2.2.0;python_version>="3.5"
tornado==5.1.1;python_version<"3.5"
tornado==6.1;python_version>="3.5"
allure-pytest==2.8.22;python_version<"3.5"
allure-pytest==2.8.36;python_version>="3.5"
pdfminer.six==20191110;python_version<"3.5"
pdfminer.six==20201018;python_version>="3.5"
# --- Testing Requirements --- #
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)
coverage==5.5
pytest-cov==2.11.1
flake8==3.7.9;python_version<"3.5"
flake8==3.9.0;python_version>="3.5"
pyflakes==2.1.1;python_version<"3.5"
pyflakes==2.3.0;python_version>="3.5"
pycodestyle==2.5.0;python_version<"3.5"
pycodestyle==2.7.0;python_version>="3.5"

View File

@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "1.57.1"
__version__ = "1.58.0"

View File

@ -4003,7 +4003,7 @@ class BaseCase(unittest.TestCase):
'<script src="%s"></script>\n'
'<script src="%s"></script>\n'
'<script>Reveal.initialize('
'{showNotes: %s, slideNumber: true, hash: false, '
'{showNotes: %s, slideNumber: true, progress: true, hash: false, '
'autoSlide: %s,});'
'</script>\n'
'</body>\n'
@ -4086,20 +4086,23 @@ class BaseCase(unittest.TestCase):
def create_pie_chart(
self, chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, libs=True):
data_name=None, unit=None, libs=True, labels=True, legend=True):
""" Creates a JavaScript pie chart using "HighCharts".
@Params
chart_name - If creating multiple charts,
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
if not chart_name:
chart_name = "default"
@ -4108,24 +4111,28 @@ class BaseCase(unittest.TestCase):
style = "pie"
self.__create_highchart(
chart_name=chart_name, title=title, subtitle=subtitle,
style=style, data_name=data_name, unit=unit, libs=libs)
style=style, data_name=data_name, unit=unit, libs=libs,
labels=labels, legend=legend)
def create_bar_chart(
self, chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, libs=True):
data_name=None, unit=None, libs=True, labels=True, legend=True):
""" Creates a JavaScript bar chart using "HighCharts".
@Params
chart_name - If creating multiple charts,
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
if not chart_name:
chart_name = "default"
@ -4134,24 +4141,28 @@ class BaseCase(unittest.TestCase):
style = "bar"
self.__create_highchart(
chart_name=chart_name, title=title, subtitle=subtitle,
style=style, data_name=data_name, unit=unit, libs=libs)
style=style, data_name=data_name, unit=unit, libs=libs,
labels=labels, legend=legend)
def create_column_chart(
self, chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, libs=True):
data_name=None, unit=None, libs=True, labels=True, legend=True):
""" Creates a JavaScript column chart using "HighCharts".
@Params
chart_name - If creating multiple charts,
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
libs - The option to include Chart libraries (JS and CSS files).
Should be set to True (default) for the first time creating
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
if not chart_name:
chart_name = "default"
@ -4160,18 +4171,21 @@ class BaseCase(unittest.TestCase):
style = "column"
self.__create_highchart(
chart_name=chart_name, title=title, subtitle=subtitle,
style=style, data_name=data_name, unit=unit, libs=libs)
style=style, data_name=data_name, unit=unit, libs=libs,
labels=labels, legend=legend)
def create_line_chart(
self, chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, zero=False, libs=True):
data_name=None, unit=None, zero=False, libs=True,
labels=True, legend=True):
""" Creates a JavaScript line chart using "HighCharts".
@Params
chart_name - If creating multiple charts,
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
zero - If True, the y-axis always starts at 0. (Default: False).
libs - The option to include Chart libraries (JS and CSS files).
@ -4179,6 +4193,8 @@ class BaseCase(unittest.TestCase):
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
if not chart_name:
chart_name = "default"
@ -4187,18 +4203,21 @@ class BaseCase(unittest.TestCase):
style = "line"
self.__create_highchart(
chart_name=chart_name, title=title, subtitle=subtitle,
style=style, data_name=data_name, unit=unit, zero=zero, libs=libs)
style=style, data_name=data_name, unit=unit, zero=zero, libs=libs,
labels=labels, legend=legend)
def create_area_chart(
self, chart_name=None, title=None, subtitle=None,
data_name=None, unit=None, zero=False, libs=True):
data_name=None, unit=None, zero=False, libs=True,
labels=True, legend=True):
""" Creates a JavaScript area chart using "HighCharts".
@Params
chart_name - If creating multiple charts,
use this to select which one.
title - The title displayed for the chart.
subtitle - The subtitle displayed for the chart.
data_name - Set the series name. Useful for multi-series charts.
data_name - The series name. Useful for multi-series charts.
If no data_name, will default to using "Series 1".
unit - The description label given to the chart's y-axis values.
zero - If True, the y-axis always starts at 0. (Default: False).
libs - The option to include Chart libraries (JS and CSS files).
@ -4206,6 +4225,8 @@ class BaseCase(unittest.TestCase):
a chart on a web page. If creating multiple charts on the
same web page, you won't need to re-import the libraries
when creating additional charts.
labels - If True, displays labels on the chart for data points.
legend - If True, displays the data point legend on the chart.
"""
if not chart_name:
chart_name = "default"
@ -4214,11 +4235,13 @@ class BaseCase(unittest.TestCase):
style = "area"
self.__create_highchart(
chart_name=chart_name, title=title, subtitle=subtitle,
style=style, data_name=data_name, unit=unit, zero=zero, libs=libs)
style=style, data_name=data_name, unit=unit, zero=zero, libs=libs,
labels=labels, legend=legend)
def __create_highchart(
self, chart_name=None, title=None, subtitle=None,
style=None, data_name=None, unit=None, zero=False, libs=True):
style=None, data_name=None, unit=None, zero=False, libs=True,
labels=True, legend=True):
""" Creates a JavaScript chart using the "HighCharts" library. """
if not chart_name:
chart_name = "default"
@ -4232,6 +4255,14 @@ class BaseCase(unittest.TestCase):
data_name = "Series 1"
if not unit:
unit = "Values"
if labels:
labels = "true"
else:
labels = "false"
if legend:
legend = "true"
else:
legend = "false"
title = title.replace("'", "\\'")
subtitle = subtitle.replace("'", "\\'")
unit = unit.replace("'", "\\'")
@ -4355,25 +4386,45 @@ class BaseCase(unittest.TestCase):
padding: '6px',
fontSize: '14px'
},
backgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, 'rgba(255, 255, 255, 0.78)'],
[0.5, 'rgba(235, 235, 235, 0.76)'],
[1, 'rgba(244, 252, 255, 0.74)']
]
},
hideDelay: 40,
pointFormat: '%s'
},
""" % point_format)
chart_init_3 = (
r"""
"""
accessibility: {
point: {
valueSuffix: '%'
valueSuffix: '%%'
}
},
plotOptions: {
series: {
states: {
inactive: {
opacity: 0.85
}
}
},
pie: {
size: "95%",
size: "95%%",
allowPointSelect: true,
animation: false,
cursor: 'pointer',
dataLabels: {
// enabled: false,
// format: '{point.name}: {point.y:.0f}',
enabled: %s,
formatter: function() {
if (this.y > 0) {
return this.point.name + ': ' + this.point.y
@ -4385,10 +4436,10 @@ class BaseCase(unittest.TestCase):
enabled: true
}
},
showInLegend: true
showInLegend: %s
}
},
""")
""" % (labels, legend))
if style != "pie":
chart_init_3 = (
"""
@ -4406,11 +4457,11 @@ class BaseCase(unittest.TestCase):
},
plotOptions: {
series: {
showInLegend: true,
animation: false,
dataLabels: {
enabled: true
enabled: %s
},
showInLegend: %s,
animation: false,
shadow: false,
lineWidth: 3,
fillOpacity: 0.5,
@ -4419,7 +4470,7 @@ class BaseCase(unittest.TestCase):
}
}
},
""")
""" % (labels, legend))
chart_init = chart_init_1 + chart_init_2 + chart_init_3
color_by_point = "true"
if style != "pie":
@ -5308,9 +5359,11 @@ class BaseCase(unittest.TestCase):
############
def generate_referral(self, start_page, destination_page):
def generate_referral(self, start_page, destination_page, selector=None):
""" This method opens the start_page, creates a referral link there,
and clicks on that link, which goes to the destination_page.
If a selector is given, clicks that on the destination_page,
which can prevent an artificial rise in website bounce-rate.
(This generates real traffic for testing analytics software.) """
self.__check_scope()
if not page_utils.is_valid_url(destination_page):
@ -5336,17 +5389,19 @@ class BaseCase(unittest.TestCase):
self.click(
"a.analytics.referral.test", timeout=2) # Clicks generated button
time.sleep(0.15)
try:
self.click("html")
time.sleep(0.08)
except Exception:
pass
if selector:
self.click(selector)
time.sleep(0.15)
def generate_traffic(self, start_page, destination_page, loops=1):
""" Similar to generate_referral(), but can do multiple loops. """
def generate_traffic(
self, start_page, destination_page, loops=1, selector=None):
""" Similar to generate_referral(), but can do multiple loops.
If a selector is given, clicks that on the destination_page,
which can prevent an artificial rise in website bounce-rate. """
self.__check_scope()
for loop in range(loops):
self.generate_referral(start_page, destination_page)
self.generate_referral(
start_page, destination_page, selector=selector)
time.sleep(0.05)
def generate_referral_chain(self, pages):

View File

@ -37,6 +37,7 @@ if sys.argv[-1] == 'publish':
'>>> Confirm release PUBLISH to PyPI? (yes/no): ')).lower().strip()
if reply == 'yes':
print("\n*** Checking code health with flake8:\n")
os.system("python -m pip install 'flake8==3.9.0'")
flake8_status = os.system("flake8 --exclude=temp")
if flake8_status != 0:
print("\nWARNING! Fix flake8 issues before publishing to PyPI!\n")
@ -107,7 +108,7 @@ setup(
'packaging>=20.9',
'setuptools>=44.1.1;python_version<"3.5"',
'setuptools>=50.3.2;python_version>="3.5" and python_version<"3.6"',
'setuptools>=54.1.1;python_version>="3.6"',
'setuptools>=54.1.2;python_version>="3.6"',
'setuptools-scm>=5.0.2',
'wheel>=0.36.2',
'attrs>=20.3.0',
@ -137,7 +138,6 @@ setup(
'pytest==4.6.11;python_version<"3.5"',
'pytest==6.1.2;python_version>="3.5" and python_version<"3.6"',
'pytest==6.2.2;python_version>="3.6"',
'pytest-cov==2.11.1',
'pytest-forked==1.3.0',
'pytest-html==1.22.1;python_version<"3.6"',
'pytest-html==2.0.1;python_version>="3.6"',
@ -163,7 +163,7 @@ setup(
'traitlets==4.3.3;python_version<"3.7"',
'traitlets==5.0.5;python_version>="3.7"',
'prompt-toolkit==1.0.18;python_version<"3.6"',
'prompt-toolkit==3.0.16;python_version>="3.6"',
'prompt-toolkit==3.0.17;python_version>="3.6"',
'ipython==5.10.0;python_version<"3.5"',
'ipython==6.5.0;python_version>="3.5" and python_version<"3.6"',
'ipython==7.16.1;python_version>="3.6" and python_version<"3.7"',
@ -174,7 +174,6 @@ setup(
'virtualenv>=20.4.2', # Sync with importlib-metadata and pathlib2
'pymysql==0.10.1;python_version<"3.6"',
'pymysql==1.0.2;python_version>="3.6"',
'coverage==5.5',
'brython==3.9.1',
'pyotp==2.6.0',
'boto==2.49.0',
@ -184,10 +183,6 @@ setup(
'Pillow==7.2.0;python_version>="3.5" and python_version<"3.6"',
'Pillow==8.1.2;python_version>="3.6"',
'rich==9.13.0;python_version>="3.6" and python_version<"4.0"',
'flake8==3.7.9;python_version<"3.5"',
'flake8==3.8.4;python_version>="3.5"',
'pyflakes==2.1.1;python_version<"3.5"',
'pyflakes==2.2.0;python_version>="3.5"',
'tornado==5.1.1;python_version<"3.5"',
'tornado==6.1;python_version>="3.5"',
'allure-pytest==2.8.22;python_version<"3.5"',
@ -195,6 +190,22 @@ setup(
'pdfminer.six==20191110;python_version<"3.5"',
'pdfminer.six==20201018;python_version>="3.5"',
],
extras_require={
# pip install -e .[coverage]
'coverage': [
'coverage==5.5',
'pytest-cov==2.11.1',
],
# pip install -e .[flake]
'flake': [
'flake8==3.7.9;python_version<"3.5"',
'flake8==3.9.0;python_version>="3.5"',
'pyflakes==2.1.1;python_version<"3.5"',
'pyflakes==2.3.0;python_version>="3.5"',
'pycodestyle==2.5.0;python_version<"3.5"',
'pycodestyle==2.7.0;python_version>="3.5"',
],
},
packages=[
'seleniumbase',
'seleniumbase.common',