Skip to content

Commit 2806b65

Browse files
authored
Merge pull request #380 from AutomationSolutionz/scroll-use-js
use js added in scroll js selenium action
2 parents 1b4f424 + 4497da7 commit 2806b65

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,7 +3180,12 @@ def Scroll(step_data):
31803180
def scroll_to_element(step_data):
31813181
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
31823182
global selenium_driver
3183+
use_js = False
31833184
try:
3185+
for row in step_data:
3186+
3187+
if "use js" in row[0].lower():
3188+
use_js = row[2].strip().lower() in ("true", "yes", "1")
31843189
scroll_element = LocateElement.Get_Element(step_data, selenium_driver)
31853190
if scroll_element in failed_tag_list:
31863191
CommonUtil.ExecLog(
@@ -3193,9 +3198,13 @@ def scroll_to_element(step_data):
31933198
"Element to which instructed to scroll has been found. Scrolling to view it",
31943199
1,
31953200
)
3196-
actions = ActionChains(selenium_driver)
3197-
actions.move_to_element(scroll_element)
3198-
actions.perform()
3201+
if use_js:
3202+
selenium_driver.execute_script("arguments[0].scrollIntoView(true);", scroll_element)
3203+
else:
3204+
actions = ActionChains(selenium_driver)
3205+
3206+
actions.move_to_element(scroll_element)
3207+
actions.perform()
31993208
return "passed"
32003209

32013210
except Exception:

0 commit comments

Comments
 (0)