Blazemeter / taurus

@@ -22,12 +22,13 @@
Loading
22 22
from urllib import parse
23 23
24 24
import astunparse
25 +
import selenium
25 26
26 27
from bzt import TaurusConfigError, TaurusInternalException
27 28
from bzt.engine import Scenario
28 29
from bzt.requests_model import HTTPRequest, HierarchicRequestParser, TransactionBlock, \
29 30
    SetVariables, IncludeScenarioBlock
30 -
from bzt.utils import iteritems, dehumanize_time, ensure_is_dict
31 +
from bzt.utils import iteritems, dehumanize_time, ensure_is_dict, is_selenium_4
31 32
from .ast_helpers import ast_attr, ast_call, gen_empty_line_stmt, gen_store, gen_subscript
32 33
from .jmeter_functions import JMeterExprCompiler
33 34
@@ -987,23 +988,21 @@
Loading
987 988
            return []
988 989
989 990
    def _get_options(self, browser):
990 -
        if browser == 'firefox':
991 -
            options = self._get_firefox_options()
992 -
        elif browser == 'chrome':
993 -
            options = self._get_chrome_options()
994 -
        elif browser == 'remote':
991 +
        if browser == 'remote':
995 992
            if 'firefox' == self.capabilities.get('browserName'):
996 993
                browser = 'firefox'
997 -
                options = self._get_firefox_options()
998 994
            elif 'chrome' == self.capabilities.get('browserName'):
999 995
                browser = 'chrome'
1000 -
                options = self._get_chrome_options()
1001 -
            else:
1002 -
                options = [ast.Assign(targets=[ast_attr("options")], value=ast_attr("None"))]
996 +
        if browser == 'firefox':
997 +
            options = self._get_firefox_options()
998 +
        elif browser == 'chrome':
999 +
            options = self._get_chrome_options()
1003 1000
        else:
1004 1001
            options = [ast.Assign(targets=[ast_attr("options")], value=ast_attr("None"))]
1005 1002
1006 1003
        if self.OPTIONS in self.executor.settings:
1004 +
            self.log.debug(f'Generating selenium option {self.executor.settings.get(self.OPTIONS)}. '
1005 +
                           f'Browser {browser}. Selenium version {selenium.__version__}')
1007 1006
            options.extend(self._get_selenium_options(browser))
1008 1007
1009 1008
        return options
@@ -1096,12 +1095,9 @@
Loading
1096 1095
                        value=ast.Name(id="options"))]))
1097 1096
1098 1097
    def _get_selenium_options(self, browser):
1099 -
        import selenium
1100 -
        from distutils.version import LooseVersion
1101 -
        selenium_version = LooseVersion(selenium.__version__)
1102 -
1103 1098
        options = []
1104 -
        if selenium_version < LooseVersion('4'):
1099 +
1100 +
        if not is_selenium_4():
1105 1101
            old_version = True
1106 1102
            if browser != 'firefox' and browser != 'chrome':
1107 1103
                self.log.warning(f'Selenium options are not supported. '
@@ -1118,13 +1114,11 @@
Loading
1118 1114
                        func=ast_attr("webdriver.ArgOptions")))])
1119 1115
1120 1116
        for opt in self.executor.settings.get(self.OPTIONS):
1121 -
            self.log.debug(f'Option {opt}. Browser {browser}. Selenium version {selenium.__version__}')
1122 -
1123 -
            if opt == "ignore_proxy":
1117 +
            if opt == "ignore-proxy":
1124 1118
                options.extend(self._get_ignore_proxy(old_version))
1125 1119
            elif opt == "arguments":
1126 1120
                options.extend(self._get_arguments())
1127 -
            elif opt == "experimental_options":
1121 +
            elif opt == "experimental-options":
1128 1122
                options.extend(self._get_experimental_options(browser))
1129 1123
            elif opt == "preferences":
1130 1124
                options.extend(self._get_preferences(browser))
@@ -1134,16 +1128,15 @@
Loading
1134 1128
        return options
1135 1129
1136 1130
    def _get_ignore_proxy(self, old_version):
1137 -
        ignore_proxy = "ignore_proxy"
1131 +
        ignore_proxy = "ignore-proxy"
1138 1132
1139 1133
        if old_version:
1140 1134
            self.log.warning(f'Option {ignore_proxy} is not supported for this selenium version')
1141 1135
            return []
1142 -
        if self.executor.settings.get(self.OPTIONS).get(ignore_proxy) is not True:
1136 +
        if not self.executor.settings.get(self.OPTIONS).get(ignore_proxy):
1143 1137
            return []
1144 1138
1145 -
        return [ast.Expr(
1146 -
            ast_call(func=ast_attr("options.ignore_local_proxy_environment_variables")))]
1139 +
        return [ast.Expr(ast_call(func=ast_attr("options.ignore_local_proxy_environment_variables")))]
1147 1140
1148 1141
    def _get_arguments(self):
1149 1142
        args = []
@@ -1158,7 +1151,7 @@
Loading
1158 1151
        return args
1159 1152
1160 1153
    def _get_experimental_options(self, browser):
1161 -
        experimental_options = "experimental_options"
1154 +
        experimental_options = "experimental-options"
1162 1155
1163 1156
        if browser != "chrome":
1164 1157
            self.log.warning(f'Option {experimental_options} is not supported for {browser}')

@@ -42,6 +42,7 @@
Loading
42 42
import traceback
43 43
import webbrowser
44 44
import zipfile
45 +
import selenium
45 46
from abc import abstractmethod
46 47
from collections import defaultdict, Counter
47 48
from contextlib import contextmanager
@@ -283,6 +284,10 @@
Loading
283 284
    return result
284 285
285 286
287 +
def is_selenium_4():
288 +
    return LooseVersion(selenium.__version__) >= LooseVersion('4')
289 +
290 +
286 291
class BetterDict(defaultdict):
287 292
    """
288 293
    Wrapper for defaultdict that able to deep merge other dicts into itself
Files Coverage
bzt 90.32%
Project Totals (70 files) 90.32%
9241.2
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
1
codecov:
2
  notify:
3
    require_ci_to_pass: yes
4

5
coverage:
6
  round: up
7

8
ignore:
9
  - bzt/resources
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading