def get_tracker_state(self): """Parse the UI to group all third party origins into their respective action states.""" self.notYetBlocked = {} self.cookieBlocked = {} self.blocked = {} self.driver.switch_to.window(self.driver.current_window_handle) domain_divs = self.driver.find_elements_by_css_selector( "#blockedResourcesInner > div.clicker[data-origin]") for div in domain_divs: origin = div.get_attribute('data-origin') # assert that this origin is never duplicated in the UI self.assertNotIn(origin, self.notYetBlocked) self.assertNotIn(origin, self.cookieBlocked) self.assertNotIn(origin, self.blocked) # get slider state for given origin action_type = get_domain_slider_state(self.driver, origin) # non-tracking domains are hidden by default # so if we see a slider set to "allow", # it must be in the tracking-but-not-yet-blocked section if action_type == 'allow': self.notYetBlocked[origin] = True elif action_type == 'cookieblock': self.cookieBlocked[origin] = True elif action_type == 'block': self.blocked[origin] = True else: self.fail("what is this?!? %s" % action_type)
def get_tracker_state(self): """Parse the UI to group all third party origins into their respective action states.""" self.nonTrackers = {} self.cookieBlocked = {} self.blocked = {} self.driver.switch_to.window(self.driver.current_window_handle) domain_divs = self.driver.find_elements_by_css_selector( "#blockedResourcesInner > div.clicker[data-origin]") for div in domain_divs: origin = div.get_attribute('data-origin') # assert that this origin is never duplicated in the UI self.assertTrue(origin not in self.nonTrackers) self.assertTrue(origin not in self.cookieBlocked) self.assertTrue(origin not in self.blocked) # get slider state for given origin action_type = get_domain_slider_state(self.driver, origin) if action_type == 'allow': self.nonTrackers[origin] = True elif action_type == 'noaction': self.nonTrackers[origin] = True elif action_type == 'cookieblock': self.cookieBlocked[origin] = True elif action_type == 'block': self.blocked[origin] = True else: print("what is this?!? " + str(action_type)) self.assertTrue(False) # pylint: disable=redundant-unittest-assert