hugo_themes_report/test/test_scroll.py

44 lines
1.7 KiB
Python
Raw Normal View History

2021-08-21 16:05:41 -07:00
from test.test_selenium import TestSelenium
from unittest import TestCase
class TestScroll(TestSelenium, TestCase):
def setUp(self):
super(TestScroll, self).setUp()
self.plus_button = self.driver.find_element_by_id('plus-button')
self.minus_button = self.driver.find_element_by_id('minus-button')
def test_get_scroll_position(self):
self.assertEqual(
self.driver.execute_script("return window.pageYOffset"), 0)
self.driver.execute_script(
"window.scrollTo(0,document.body.scrollHeight)"
)
2021-09-08 15:07:41 -07:00
self.assertGreaterEqual(
self.driver.execute_script("return window.pageYOffset"), 12061)
2021-08-21 16:05:41 -07:00
def test_plus_button_scroll_to_top(self):
self.assertEqual(
self.driver.execute_script("return window.pageYOffset"), 0)
self.driver.execute_script(
"window.scrollTo(0,document.body.scrollHeight)"
)
2021-09-08 15:07:41 -07:00
self.assertGreaterEqual(
self.driver.execute_script("return window.pageYOffset"), 12061)
2021-08-21 16:05:41 -07:00
self.plus_button.click()
self.assertEqual(
self.driver.execute_script("return window.pageYOffset"), 0)
def test_minus_button_scroll_to_top(self):
self.plus_button.click()
self.assertEqual(
self.driver.execute_script("return window.pageYOffset"), 0)
self.driver.execute_script(
"window.scrollTo(0,document.body.scrollHeight)"
)
2021-09-08 15:07:41 -07:00
self.assertGreaterEqual(
self.driver.execute_script("return window.pageYOffset"), 12125)
2021-08-21 16:05:41 -07:00
self.minus_button.click()
self.assertEqual(
self.driver.execute_script("return window.pageYOffset"), 0)