# Buggy code
def is_active(input_element):
    """Check if we can interact with the given element."""
    try:
        return input_element.is_displayed() and input_element.is_enabled()
    except WebDriverException:
        return False


# Traceback (StaleElementReferenceException)
TaskManager          - INFO     -

OpenWPM Version: v0.8.0-137-gb0a8e00
Firefox Version: 52.4.1

========== Browser Configuration ==========
Keys:
{
"crawl_id": 0,
"adblock-plus": 1,
"bot_mitigation": 2,
"browser": 3,
"cookie_instrument": 4,
"cp_instrument": 5,
"disable_flash": 6,
"disconnect": 7,
"donottrack": 8,
"extension_enabled": 9,
"ghostery": 10,
"headless": 11,
"http_instrument": 12,
"https-everywhere": 13,
"js_instrument": 14,
"prefs": 15,
"random_attributes": 16,
"save_all_content": 17,
"save_javascript": 18,
"tp_cookies": 19,
"tracking-protection": 20,
"ublock-origin": 21
}

0  1      2      3        4      5      6      7      8      9     10     11    12    13     14     15    16     17     18     19      20     21
---  -----  -----  -------  -----  -----  -----  -----  -----  ----  -----  ----  ----  -----  -----  ----  -----  -----  -----  ------  -----  -----
19  False  False  firefox  False  False  False  False  False  True  False  True  True  False  False  {}    False  False  False  always  False  False

========== Input profile tar files ==========
No profile tar files specified

========== Output (archive) profile dirs ==========
No profile archive directories specified



BrowserManager       - INFO     - BROWSER 19: EXECUTING COMMAND: ('BROWSE', 'http://www.en.aau.dk/', 50, 0, 16)
Using psl from cache: /tmp/public_suffix_list.dat
browser_commands     - INFO     - BROWSER 19: visiting internal link http://www.en.aau.dk/news/
browser_commands     - INFO     - BROWSER 19: visiting internal link http://www.en.aau.dk/cooperation/
browser_commands     - INFO     - BROWSER 19: visiting internal link http://www.en.aau.dk/events/
browser_commands     - INFO     - BROWSER 19: visiting internal link http://www.vacancies.aau.dk/
BrowserManager       - INFO     - BROWSER 19: Crash in driver, restarting browser manager
Traceback (most recent call last):
File "/user/es.aau.dk/sok/OpenWPM/automation/BrowserManager.py", line 404, in BrowserManager
browser_params, manager_params, extension_socket)
File "/user/es.aau.dk/sok/OpenWPM/automation/Commands/command_executor.py", line 22, in execute_command
extension_socket=extension_socket)
File "/user/es.aau.dk/sok/OpenWPM/automation/Commands/browser_commands.py", line 189, in browse_website
if x.is_displayed() is True]
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 363, in is_displayed
return self._execute(Command.IS_ELEMENT_DISPLAYED)['value']
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 501, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
StaleElementReferenceException: Message: The element reference of <a class="mobileMenu topLink"> stale: either the element is no longer attached to the DOM or the page has been refreshed


TaskManager          - INFO     - BROWSER 19: Received failure status while executing command: BROWSE

# Fixed code
def is_active(input_element):
    """Check if we can interact with the given element."""
    try:
        return is_displayed(input_element) and input_element.is_enabled()
    except WebDriverException:
        return False