I am trying to write a function that will scroll the page down to a specific element on the page. But it is not working. I am using Python + Selenium + Gherkin
My BasePage.py file
def scroll_page(self, by_locator):
element = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator))
self.driver.execute_script("arguments[0].scrollIntoView();", element)
My HomePage.py file
from pages.BasePage import BasePage
from selenium.webdriver.common.by import By
class HomePage(BasePage):
ManageTipsPreferencesButton = (By.XPATH, "//*[@id='root']/main/div[2]/div[2]/ul/li[1]/a[2]")
def __init__(self, driver):
super().__init__(driver)
def scrollPage(self):
self.scroll_page(self.ManageTipsPreferencesButton)
My steps.py file
@step("Scroll page to the bottom")
def step_impl(context):
try:
context.home_page.scrollPage()
except:
context.driver.close()
assert False, "Exception! Can not scroll page"
Always assert Fales "Exception! Can not scroll page"
I do knot now where is bug. Many thanks for help