is where the error occurs, then I would assume shadow_root1 does not have what you think it should have in it.
I also notice you are using the find_element_by_tag_name method but passing something called settings-ui. I am not aware of any tag in HTML named settings-ui. Are you sure that is not a class name or id?
Oh I see now. It appears they have created a custom element named “downloads manager” when looking at the SO article. I have not used Selenium enough to understand what is going on here. Also, it is not even clear if any of the solutions showing this code are valid as the ones containing code were not accepted as a solution.
What does the HTML file you are using against the code above look like? It might help us to understand what you are at least trying to do. Also, is this the full Python code?
EDIT: The code referenced in the SO article is talking about using Selenium with a Shadow DOM. I assume you have generated a Shadow DOM and that is why you are trying to use this code?
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.