Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from selenium.webdriver.common.by import By
from selenium import webdriver
import unittest
import time
class WebKitFeatureStatusTest(unittest.TestCase):
def test_feature_status_page_search(self):
self.driver.get("https://webkit.org/status/")
search_box = self.driver.find_element_by_id("search")
search_box.send_keys("CSS")
value = search_box.get_attribute("value")
self.assertTrue(len(value) > 0)
search_box.submit()
feature_count = self.shown_feature_count()
self.assertTrue(feature_count > 0)
def test_feature_status_page_filters(self):
self.driver.get("https://webkit.org/status/")
time.sleep(5)
filters = self.driver.find_elements(By.CSS_SELECTOR, "ul.status-filters li input")
self.assertTrue(len(filters) is 7)
for checked_filter in filter(lambda f: f.is_selected(), filters):
checked_filter.click()
unfiltered_count = self.shown_feature_count()
running_count = 0
for filt in filters:
filt.click()
self.assertTrue(filt.is_selected())
running_count += self.shown_feature_count()
filt.click()
self.assertTrue(running_count is unfiltered_count)
def shown_feature_count(self):
return len(self.driver.execute_script("return document.querySelectorAll('li.feature:not(.is-hidden)')"))
@classmethod
def setUpClass(module):
WebKitFeatureStatusTest.driver = webdriver.Safari()
@classmethod
def tearDownClass(module):
WebKitFeatureStatusTest.driver.quit()
if __name__ == '__main__':
unittest.main()
@Abouhassane

This comment has been minimized.

Copy link

commented Apr 2, 2019

I keep getting this error AttributeError: 'WebKitFeatureStatusTest' object has no attribute 'driver'. any idea why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.