(driver, element, *args, **kwargs)
| 1342 | |
| 1343 | |
| 1344 | def slow_scroll_to_element(driver, element, *args, **kwargs): |
| 1345 | if driver.capabilities["browserName"] == "internet explorer": |
| 1346 | # IE breaks on slow-scrolling. Do a fast scroll instead. |
| 1347 | scroll_to_element(driver, element) |
| 1348 | return |
| 1349 | scroll_position = execute_script(driver, "return window.scrollY;") |
| 1350 | element_location_y = None |
| 1351 | try: |
| 1352 | if shared_utils.is_cdp_swap_needed(driver): |
| 1353 | element_location_y = element.get_position().y |
| 1354 | else: |
| 1355 | element_location_y = element.location["y"] |
| 1356 | except Exception: |
| 1357 | if shared_utils.is_cdp_swap_needed(driver): |
| 1358 | element.scroll_into_view() |
| 1359 | else: |
| 1360 | element.location_once_scrolled_into_view |
| 1361 | return |
| 1362 | try: |
| 1363 | if shared_utils.is_cdp_swap_needed(driver): |
| 1364 | element_location_x = element.get_position().x |
| 1365 | else: |
| 1366 | element_location_x = element.location["x"] |
| 1367 | except Exception: |
| 1368 | element_location_x = 0 |
| 1369 | try: |
| 1370 | if shared_utils.is_cdp_swap_needed(driver): |
| 1371 | element_width = element.get_position().width |
| 1372 | else: |
| 1373 | element_width = element.size["width"] |
| 1374 | except Exception: |
| 1375 | element_width = 0 |
| 1376 | try: |
| 1377 | if shared_utils.is_cdp_swap_needed(driver): |
| 1378 | screen_width = driver.cdp.get_window_size()["width"] |
| 1379 | else: |
| 1380 | screen_width = driver.get_window_size()["width"] |
| 1381 | except Exception: |
| 1382 | screen_width = execute_script(driver, "return window.innerWidth;") |
| 1383 | element_location_y = element_location_y - constants.Scroll.Y_OFFSET |
| 1384 | if element_location_y < 0: |
| 1385 | element_location_y = 0 |
| 1386 | element_location_x_fix = element_location_x - 400 |
| 1387 | if element_location_x_fix < 0: |
| 1388 | element_location_x_fix = 0 |
| 1389 | if element_location_x + element_width <= screen_width: |
| 1390 | element_location_x_fix = 0 |
| 1391 | if shared_utils.is_cdp_swap_needed(driver): |
| 1392 | distance = element_location_y |
| 1393 | else: |
| 1394 | distance = element_location_y - scroll_position |
| 1395 | if distance != 0: |
| 1396 | total_steps = int(abs(distance) / 50.0) + 2.0 |
| 1397 | step_value = float(distance) / total_steps |
| 1398 | new_position = scroll_position |
| 1399 | for y in range(int(total_steps)): |
| 1400 | time.sleep(0.011) |
| 1401 | new_position += step_value |
nothing calls this directly
no test coverage detected
searching dependent graphs…