[🐛 Bug]: AttributeError: 'dict' object has no attribute 'is_displayed'
See original GitHub issueWhat happened?
Within the expected_conditions.py support package of selenium python,
is_displayed()
does not appear to be a function of:
from selenium.webdriver.remote.webdriver import WebElement
So, when attempting to:
WebDriverWait(webdriver, 30).until(ec.element_to_be_clickable((By.ID, "username")))
The following is produced from shell:
AttributeError: ‘dict’ object has no attribute ‘is_displayed’
I’ve attached the python file that would reproduce the bug. Please help. Thanks!
How can we reproduce the issue?
from selenium import webdriver
from selenium.common.exceptions import WebDriverException, TimeoutException, \
ElementClickInterceptedException, ElementNotVisibleException, \
ElementNotInteractableException, NoSuchElementException, UnexpectedAlertPresentException, StaleElementReferenceException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.wait import WebDriverWait
def browser_settings(user_agent):
"""
Inits the chrome browser with headless setting and user agent
:param headless_mode: Boolean
:param user_agent: String
:return: webdriver obj
"""
service = Service('drivers/chromedriver')
options = Options()
options.add_argument(f'user-agent={user_agent}')
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_experimental_option('w3c', False)
prefs = {
"profile.default_content_setting_values.geolocation": 2,
'profile.default_content_setting_values.notifications': 2,
'profile.content_settings.exceptions.notifications': 2,
'profile.default_content_settings.geolocation': 2,
"profile.managed_default_content_settings.popups": 2,
"profile.managed_default_content_settings.notifications": 2,
#"profile.managed_default_content_settings.images": 2,
#"profile.default_content_settings.images": 2,
'profile.content_settings.exceptions.geolocation': 2,
"profile.managed_default_content_settings.infobar": 2,
'profile.managed_default_content_settings.geolocation': 2,
'credentials_enable_service': False,
'profile': {
'password_manager_enabled': False
}
}
options.add_experimental_option("prefs", prefs)
chrome_obj = webdriver.Chrome(service=service, options=options)
return chrome_obj
userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15"
browser = browser_settings(userAgent)
browser.get('https://account.protonmail.com/login')
WebDriverWait(browser, 30).until(ec.element_to_be_clickable((By.ID, "username")))
browser.find_element(By.ID, "username").send_keys("email_address@protonmail.com")
time.sleep(7)
browser.quit()
Relevant log output
Traceback (most recent call last):
File "Y:\For filing a report.py", line 58, in <module>
WebDriverWait(browser, 10).until(ec.element_to_be_clickable((By.NAME, "loginfmt")))
File "C:\Users\Lovelace\AppData\Local\Programs\Python\Python310-32\lib\site-packages\selenium\webdriver\support\wait.py", line 78, in until
value = method(self._driver)
File "C:\Users\Lovelace\AppData\Local\Programs\Python\Python310-32\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 332, in _predicate
target = visibility_of(target)(driver)
File "C:\Users\Lovelace\AppData\Local\Programs\Python\Python310-32\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 143, in _predicate
return _element_if_visible(element)
File "C:\Users\Lovelace\AppData\Local\Programs\Python\Python310-32\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 154, in _element_if_visible
return element if element.is_displayed() == visibility else False
AttributeError: 'dict' object has no attribute 'is_displayed'
Operating System
Windows 10 Pro 32-bit
Selenium version
Selenium 4.0.0; Python 3.10.150.0
What are the browser(s) and version(s) where you see this issue?
Chrome 96.0.4664.45
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 96.0.4664.45
Are you using Selenium Grid?
No
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
'list' object has no attribute 'isDisplayed' Python Selenium
I get the error: AttributeError: 'list' object has no attribute 'isDisplayed'. My whole code: import time import asyncio import colorama ...
Read more >Selenium WebDriver Error AttributeError list object has no ...
Your answer The error is because your using driver. find_elements instead of driver. find_element. That's a syntactical mistake.
Read more >Python + Selenium 4.0+ (AttributeError: 'dict' object has no ...
First, this error doesn't make sense. If Selenium is getting a return value from find_element() it isn't going to be a dict unless...
Read more >7. WebDriver API — Selenium Python Bindings 2 documentation
Thrown when the attribute of element could not be found. You may want to check if the attribute exists in the particular browser...
Read more >AttributeError: 'WebElement' object has no attribute 'send_Keys'
I try to code a web automation with Selenium but I always get the error message: textArea.send_Keys(username) AttributeError: 'WebElement' object has no ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re passing in options.add_experimental_option(‘w3c’, False) which is causing this. Either remove that or downgrade chrome and selenium. On Nov 21, 2021, 9:49 PM +0000, github-actions[bot] @.***>, wrote:
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.