Blazemeter / taurus
Showing 1 of 2 files from the diff.

@@ -934,22 +934,15 @@
Loading
934 934
        body = [ast.Assign(targets=[ast_attr("self.driver")], value=ast_attr("None"))]
935 935
936 936
        browser = self._check_platform()
937 -
        if self.OPTIONS in self.executor.settings:
938 -
            body.extend(self._get_selenium_options(browser))
937 +
        body.extend(self._get_options(browser))
939 938
940 939
        if browser == 'firefox':
941 -
            body.extend(self._get_firefox_options() + self._get_firefox_profile() + [self._get_firefox_webdriver()])
940 +
            body.extend(self._get_firefox_profile() + [self._get_firefox_webdriver()])
942 941
943 942
        elif browser == 'chrome':
944 -
            body.extend(self._get_chrome_options() + [self._get_chrome_webdriver()])
943 +
            body.extend([self._get_chrome_webdriver()])
945 944
946 945
        elif browser == 'remote':
947 -
            if 'firefox' == self.capabilities.get('browserName'):
948 -
                body.append(self._get_firefox_options())
949 -
            else:
950 -
                empty_options = ast.Assign(targets=[ast_attr("options")], value=ast_attr("None"))
951 -
                body.append(empty_options)
952 -
953 946
            body.append(self._get_remote_webdriver())
954 947
955 948
        else:
@@ -994,6 +987,24 @@
Loading
994 987
        else:
995 988
            return []
996 989
990 +
    def _get_options(self, browser):
991 +
        if browser == 'firefox':
992 +
            options = self._get_firefox_options()
993 +
        elif browser == 'chrome':
994 +
            options = self._get_chrome_options()
995 +
        elif browser == 'remote':
996 +
            if 'firefox' == self.capabilities.get('browserName'):
997 +
                options = self._get_firefox_options()
998 +
            else:
999 +
                options = [ast.Assign(targets=[ast_attr("options")], value=ast_attr("None"))]
1000 +
        else:
1001 +
            options = [ast.Assign(targets=[ast_attr("options")], value=ast_attr("None"))]
1002 +
1003 +
        if self.OPTIONS in self.executor.settings:
1004 +
            options.extend(self._get_selenium_options(browser))
1005 +
1006 +
        return options
1007 +
997 1008
    def _get_firefox_options(self):
998 1009
        firefox_options = [
999 1010
            ast.Assign(
@@ -1082,45 +1093,78 @@
Loading
1082 1093
                        value=ast.Name(id="options"))]))
1083 1094
1084 1095
    def _get_selenium_options(self, browser):
1085 -
        result = []
1096 +
        import selenium
1097 +
        from distutils.version import LooseVersion
1098 +
        selenium_version = LooseVersion(selenium.__version__)
1099 +
1100 +
        options = []
1101 +
        if selenium_version < LooseVersion('4'):
1102 +
            old_version = True
1103 +
            if browser != 'firefox' and browser != 'chrome':
1104 +
                self.log.warning("Selenium options are not supported. "
1105 +
                                 "Browser "+browser+". Selenium version "+selenium.__version__)
1106 +
                return []
1107 +
        else:
1108 +
            old_version = False
1109 +
            if browser != 'firefox' and browser != 'chrome':
1110 +
                self.log.debug(
1111 +
                    "Generating selenium options. Browser "+browser+". Selenium version "+selenium.__version__)
1112 +
                options.extend([ast.Assign(
1113 +
                    targets=[ast.Name(id="options")],
1114 +
                    value=ast_call(
1115 +
                        func=ast_attr("webdriver.ArgOptions")))])
1116 +
1086 1117
        for opt in self.executor.settings.get(self.OPTIONS):
1087 -
            self.log.debug("Generating selenium options")
1118 +
            self.log.debug("Option "+opt+". Browser "+browser+". Selenium version "+selenium.__version__)
1088 1119
1089 1120
            if opt == "ignore_proxy":
1090 -
                result.extend(self._get_ignore_proxy())
1091 -
            if opt == "arguments":
1092 -
                result.extend(self._get_arguments())
1093 -
            if opt == "experimental_options":
1094 -
                result.extend(self._get_experimental_options(browser))
1095 -
            if opt == "preferences":
1096 -
                result.extend(self._get_preferences(browser))
1121 +
                options.extend(self._get_ignore_proxy(old_version))
1122 +
            elif opt == "arguments":
1123 +
                options.extend(self._get_arguments())
1124 +
            elif opt == "experimental_options":
1125 +
                options.extend(self._get_experimental_options(browser))
1126 +
            elif opt == "preferences":
1127 +
                options.extend(self._get_preferences(browser))
1128 +
            else:
1129 +
                self.log.warning("Unknown option " + opt)
1097 1130
1098 -
        return result
1131 +
        return options
1099 1132
1100 -
    def _get_ignore_proxy(self):
1133 +
    def _get_ignore_proxy(self, old_version):
1101 1134
        ignore_proxy = "ignore_proxy"
1102 -
        if self.executor.settings.get(self.OPTIONS).get(ignore_proxy) is True:
1103 -
            return [ast.If(
1104 -
                test=ast_attr("int(webdriver.__version__.split('.')[0]) > 3"),
1105 -
                body=ast.Expr(ast_call(func=ast_attr("options.ignore_local_proxy_environment_variables"))),
1106 -
                orelse=[])]
1107 -
        return []
1135 +
1136 +
        if old_version:
1137 +
            self.log.warning("Option "+ignore_proxy+" is not supported for this selenium version")
1138 +
            return []
1139 +
1140 +
        if self.executor.settings.get(self.OPTIONS).get(ignore_proxy) is not True:
1141 +
            return []
1142 +
1143 +
        else:
1144 +
            return [ast.Expr(
1145 +
                ast_call(func=ast_attr("options.ignore_local_proxy_environment_variables")))]
1108 1146
1109 1147
    def _get_arguments(self):
1110 1148
        args = []
1111 1149
        arguments = "arguments"
1150 +
1112 1151
        for arg in self.executor.settings.get(self.OPTIONS).get(arguments):
1113 -
            args.append(ast.Expr(
1152 +
            args.extend([ast.Expr(
1114 1153
                ast_call(
1115 1154
                    func=ast_attr("options.add_argument"),
1116 -
                    args=[ast.Str(arg, kind="")])))
1155 +
                    args=[ast.Str(arg, kind="")]))])
1156 +
1117 1157
        return args
1118 1158
1119 1159
    def _get_experimental_options(self, browser):
1120 -
        exp_opts = []
1121 1160
        experimental_options = "experimental_options"
1122 1161
1123 -
        if browser == "chrome":
1162 +
        if browser != "chrome":
1163 +
            self.log.warning("Option "+experimental_options+" is not supported for "+browser)
1164 +
            return []
1165 +
1166 +
        else:
1167 +
            exp_opts = []
1124 1168
            keys = sorted(self.executor.settings.get(self.OPTIONS).get(experimental_options))
1125 1169
            for key in keys:
1126 1170
                value = self.executor.settings.get(self.OPTIONS).get(experimental_options)[key]
@@ -1129,16 +1173,17 @@
Loading
1129 1173
                    args=[
1130 1174
                        [ast.Str(key, kind="")],
1131 1175
                        [ast.Str(value, kind="")]])))
1132 -
        else:
1133 -
            self.log.warning("Option "+experimental_options+" is not supported for "+browser)
1134 -
1135 -
        return exp_opts
1176 +
            return exp_opts
1136 1177
1137 1178
    def _get_preferences(self, browser):
1138 -
        prefers = []
1139 1179
        preferences = "preferences"
1140 1180
1141 -
        if browser == "firefox":
1181 +
        if browser != "firefox":
1182 +
            self.log.warning("Option "+preferences+" is not supported for "+browser)
1183 +
            return []
1184 +
1185 +
        else:
1186 +
            prefers = []
1142 1187
            keys = sorted(self.executor.settings.get(self.OPTIONS).get(preferences))
1143 1188
            for key in keys:
1144 1189
                value = self.executor.settings.get(self.OPTIONS).get(preferences)[key]
@@ -1147,10 +1192,8 @@
Loading
1147 1192
                    args=[
1148 1193
                        [ast.Str(key, kind="")],
1149 1194
                        [ast.Str(value, kind="")]])))
1150 -
        else:
1151 -
            self.log.warning("Option "+preferences+" is not supported for "+browser)
1152 1195
1153 -
        return prefers
1196 +
            return prefers
1154 1197
1155 1198
    @staticmethod
1156 1199
    def _gen_impl_wait(timeout):
Files Coverage
bzt 90.31%
Project Totals (70 files) 90.31%
9229.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