(
code_lines, selector_dict=None, object_dict=None, add_comments=False
)
| 220 | |
| 221 | |
| 222 | def process_test_file( |
| 223 | code_lines, selector_dict=None, object_dict=None, add_comments=False |
| 224 | ): |
| 225 | |
| 226 | seleniumbase_lines = [] |
| 227 | page_selectors = [] |
| 228 | changed = [] # The classes of page_objects.py to add to the test import |
| 229 | |
| 230 | for line in code_lines: |
| 231 | line = line.rstrip() |
| 232 | |
| 233 | # Keep lines with "%s" in them as they were |
| 234 | if r"%s" in line: |
| 235 | seleniumbase_lines.append(line) |
| 236 | continue |
| 237 | |
| 238 | # Handle self.drag_and_drop(SELECTOR, SELECTOR) |
| 239 | if not object_dict: |
| 240 | data = re.match( |
| 241 | r"""^(\s*)self\.drag_and_drop""" |
| 242 | r"""\((r?['"][\S\s]+['"]),\s?([\S\s]+)\)([\S\s]*)$""", |
| 243 | line, |
| 244 | ) |
| 245 | else: |
| 246 | data = re.match( |
| 247 | r"""^(\s*)self\.drag_and_drop""" |
| 248 | r"""\(([\S]+),\s?([\S]+)\)([\S\s]*)$""", |
| 249 | line, |
| 250 | ) |
| 251 | if data: |
| 252 | whitespace = data.group(1) |
| 253 | selector1 = "%s" % data.group(2) |
| 254 | selector1 = remove_extra_slashes(selector1) |
| 255 | page_selectors.append(selector1) |
| 256 | selector2 = "%s" % data.group(3) |
| 257 | selector2 = remove_extra_slashes(selector2) |
| 258 | page_selectors.append(selector2) |
| 259 | comments = data.group(4) |
| 260 | command = """%sself.drag_and_drop(%s, %s)%s""" % ( |
| 261 | whitespace, |
| 262 | selector1, |
| 263 | selector2, |
| 264 | comments, |
| 265 | ) |
| 266 | if selector_dict: |
| 267 | if add_comments: |
| 268 | comments = " # %s, %s" % (selector1, selector2) |
| 269 | selector1 = optimize_selector(selector1) |
| 270 | selector2 = optimize_selector(selector2) |
| 271 | if selector1 in selector_dict.keys() and ( |
| 272 | selector2 in selector_dict.keys() |
| 273 | ): |
| 274 | selector_object1 = selector_dict[selector1] |
| 275 | selector_object2 = selector_dict[selector2] |
| 276 | changed.append(selector_object1.split(".")[0]) |
| 277 | changed.append(selector_object2.split(".")[0]) |
| 278 | command = """%sself.drag_and_drop(%s, %s)%s""" % ( |
| 279 | whitespace, |
no test coverage detected
searching dependent graphs…