Skip to content

Commit ede61bd

Browse files
committed
Do some refactoring
1 parent cb742d2 commit ede61bd

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

seleniumbase/fixtures/js_utils.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,10 +1269,16 @@ def scroll_to_element(driver, element):
12691269
return False
12701270
try:
12711271
element_location_x = element.location["x"]
1272+
except Exception:
1273+
element_location_x = 0
1274+
try:
12721275
element_width = element.size["width"]
1276+
except Exception:
1277+
element_width = 0
1278+
try:
12731279
screen_width = driver.get_window_size()["width"]
12741280
except Exception:
1275-
element_location_x = 0
1281+
screen_width = execute_script("return window.innerWidth;")
12761282
element_location_y = element_location_y - constants.Scroll.Y_OFFSET
12771283
if element_location_y < 0:
12781284
element_location_y = 0
@@ -1312,10 +1318,16 @@ def slow_scroll_to_element(driver, element, *args, **kwargs):
13121318
return
13131319
try:
13141320
element_location_x = element.location["x"]
1321+
except Exception:
1322+
element_location_x = 0
1323+
try:
13151324
element_width = element.size["width"]
1325+
except Exception:
1326+
element_width = 0
1327+
try:
13161328
screen_width = driver.get_window_size()["width"]
13171329
except Exception:
1318-
element_location_x = 0
1330+
screen_width = execute_script("return window.innerWidth;")
13191331
element_location_y = element_location_y - constants.Scroll.Y_OFFSET
13201332
if element_location_y < 0:
13211333
element_location_y = 0

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
long_description = None
1010
total_description = None
1111
try:
12-
with open(os.path.join(this_dir, "README.md"), "rb") as f:
12+
with open(os.path.join(this_dir, "README.md"), mode="rb") as f:
1313
total_description = f.read().decode("utf-8")
1414
description_lines = total_description.split("\n")
1515
long_description_lines = []
@@ -21,7 +21,9 @@
2121
long_description = "A complete library for building end-to-end tests."
2222
about = {}
2323
# Get the package version from the seleniumbase/__version__.py file
24-
with open(os.path.join(this_dir, "seleniumbase", "__version__.py"), "rb") as f:
24+
with open(
25+
os.path.join(this_dir, "seleniumbase", "__version__.py"), mode="rb"
26+
) as f:
2527
exec(f.read().decode("utf-8"), about)
2628

2729
if sys.argv[-1] == "publish":

0 commit comments

Comments
 (0)