'dict' object has no attribute 'find_element_by_css_selector'

Hello Everyone,

Good day to all of you.

I am getting the above error while I run this code, as a self taught person I am finding it bit hard to understand what I have done wrong.

Any support would be highly appreciated.

Thank you.

def expand_shadow_element(element):
  shadow_root = browser.execute_script('return arguments[0].shadowRoot', element)
  return shadow_root


root1 = browser.find_element_by_tag_name('settings-ui')
shadow_root1 = expand_shadow_element(root1)

root2 = shadow_root1.find_element_by_css_selector('#main')
shadow_root2 = expand_shadow_element(root2)

root3 = shadow_root2.find_element_by_css_selector('settings-basic-page')
shadow_root3 = expand_shadow_element(root3)

root4 = shadow_root3.find_element_by_css_selector('#basicPage > settings-section:nth-child(9)')
shadow_root4 = expand_shadow_element(root4)

root5 = shadow_root4.find_element_by_css_selector('#basicPage > settings-section:nth-child(9) > settings-privacy-page')
shadow_root5 = expand_shadow_element(root5)

root6 = shadow_root5.find_element_by_css_selector('settings-clear-browsing-data-dialog')
shadow_root6 = expand_shadow_element(root6)

root7 = shadow_root6.find_element_by_css_selector('#clearBrowsingDataDialog')
shadow_root7 = expand_shadow_element(root7)

clearDataButton = shadow_root7.find_element_by_css_selector("#clearBrowsingDataConfirm")

Thank you very much for your response.

Nope it’s not. The below is the article I was referring to code the above.

Accessing shadow DOM tree with selenium

As a self taught person I didn’t know exactly what I was coding. I just tried replicating what I learnt in the post.

All I was trying to do is to click the “Clear Data” button in chrome settings.

I am actually trying to click the “Clear Data” Button of “Clear Browsing Data” on chrome ;
chrome | settings | clearBrowserData

There is a small part of code which tries to do some search and find data. This part of the script has been working fine. All I need is to access the link above and clear the cache and history apart from clearing the cookies which is already available in Python.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.