diff --git a/README.md b/README.md index d1facbe5d89..418be4f3561 100755 --- a/README.md +++ b/README.md @@ -6,21 +6,22 @@

-SeleniumBase

+SeleniumBase

+

+Latest Release on GitHub +Latest Release on PyPI

-Build fast, reliable, end-to-end tests. +End-to-end testing for the next generation.

-

-Latest Release on GitHub -Latest Release on PyPI +

SeleniumBase GitHub Actions SeleniumBase Azure Pipelines SeleniumBase SeleniumBase.io Docs

-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.

@@ -50,9 +51,8 @@ Tests are run with "pytest". Browsers are controlled by WebDriver. 🛂 MasterQA

-✅ Easy setup. Can run tests on any cloud.
-✅ Uses [Python APIs](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md) for web automation.
-✅ Can generate [test reports / dashboards](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).
+✅ Fast setup: All you need is [Python](https://www.python.org/downloads/)! 🐍
+✅ Includes [reporting & dashboard tools](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).
-------- diff --git a/examples/chart_maker/ReadMe.md b/examples/chart_maker/ReadMe.md index addc15296b9..64930305745 100755 --- a/examples/chart_maker/ReadMe.md +++ b/examples/chart_maker/ReadMe.md @@ -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. """ ``` diff --git a/examples/chart_maker/chart_presentation.py b/examples/chart_maker/chart_presentation.py index b3d15468658..d79cd7a9243 100755 --- a/examples/chart_maker/chart_presentation.py +++ b/examples/chart_maker/chart_presentation.py @@ -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 @@ def test_chart_maker_presentation(self): self.add_data_point("Failed", 1, color="#f1888f") self.add_slide("

Pie Chart

" + 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("

Bar Chart

" + 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") diff --git a/examples/chart_maker/pie_charts.py b/examples/chart_maker/pie_charts.py new file mode 100755 index 00000000000..abdf6e1fc2f --- /dev/null +++ b/examples/chart_maker/pie_charts.py @@ -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("

Lemon Meringue Pie

" + 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("

Blueberry Pie

" + 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("

Fruit Tart Pie

" + 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("

Apple Pie

" + 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("

Boston Cream Pie

" + self.extract_chart()) + + self.begin_presentation(filename="pie_charts.html") diff --git a/examples/chart_maker/test_display_chart.py b/examples/chart_maker/test_display_chart.py index 994a0a2828d..d40772b0344 100755 --- a/examples/chart_maker/test_display_chart.py +++ b/examples/chart_maker/test_display_chart.py @@ -10,13 +10,13 @@ def test_display_chart(self): 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") diff --git a/help_docs/chart_maker.md b/help_docs/chart_maker.md index addc15296b9..64930305745 100755 --- a/help_docs/chart_maker.md +++ b/help_docs/chart_maker.md @@ -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. """ ``` diff --git a/help_docs/method_summary.md b/help_docs/method_summary.md index 670b80552bd..7a3d6fde3b4 100755 --- a/help_docs/method_summary.md +++ b/help_docs/method_summary.md @@ -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) diff --git a/requirements.txt b/requirements.txt index ba3ae4f5727..734156ad7be 100755 --- a/requirements.txt +++ b/requirements.txt @@ -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" diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index bb7931bac96..11609779dfc 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "1.57.1" +__version__ = "1.58.0" diff --git a/seleniumbase/fixtures/base_case.py b/seleniumbase/fixtures/base_case.py index 2ea66acbafc..e5599ef0968 100755 --- a/seleniumbase/fixtures/base_case.py +++ b/seleniumbase/fixtures/base_case.py @@ -4003,7 +4003,7 @@ def save_presentation( '\n' '\n' '\n' '\n' @@ -4086,20 +4086,23 @@ def begin_presentation( 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 @@ def create_pie_chart( 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 @@ def create_bar_chart( 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 @@ def create_column_chart( 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 @@ def create_line_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. """ if not chart_name: chart_name = "default" @@ -4187,18 +4203,21 @@ def create_line_chart( 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 @@ def 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. """ if not chart_name: chart_name = "default" @@ -4214,11 +4235,13 @@ def create_area_chart( 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 @@ def __create_highchart( 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 @@ def __create_highchart( 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 @@ def __create_highchart( enabled: true } }, - showInLegend: true + showInLegend: %s } }, - """) + """ % (labels, legend)) if style != "pie": chart_init_3 = ( """ @@ -4406,11 +4457,11 @@ def __create_highchart( }, 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 @@ def __create_highchart( } } }, - """) + """ % (labels, legend)) chart_init = chart_init_1 + chart_init_2 + chart_init_3 color_by_point = "true" if style != "pie": @@ -5308,9 +5359,11 @@ def post_error_message(self, message, duration=None, pause=True): ############ - 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 @@ def generate_referral(self, start_page, destination_page): 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): diff --git a/setup.py b/setup.py index 4e01920d0b0..34c1d8fbc79 100755 --- a/setup.py +++ b/setup.py @@ -37,6 +37,7 @@ '>>> 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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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',