I'm attempting to access the value of navigator.plugins
from a Selenium-driven ChromeDriver initiated google-chrome Browsing Context.
Using google-chrome-devtools, I am able to retrieve navigator.userAgent
and navigator.plugins
as shown below:
https://i.sstatic.net/J7NQ3.png
However, when using Selenium's execute_script()
method, I can extract the navigator.userAgent
successfully, but trying to access navigator.plugins
results in a circular reference error:
Code Block:
from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument("start-maximized") driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe') driver.get("https://www.google.com/") print("userAgent: "+driver.execute_script("return navigator.userAgent;")) print("plugins: "+driver.execute_script("return navigator.plugins;"))
Console Output:
userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Traceback (most recent call last): File "C:\Users\Soma Bhattacharjee\Desktop\Debanjan\PyPrograms\navigator_properties.py", line 19, in <module> print("vendor: "+driver.execute_script("return navigator.plugins;")) File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 636, in execute_script 'args': converted_args})['value'] File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.JavascriptException: Message: javascript error: circular reference (Session info: chrome=83.0.4103.116)
I have read about dealing with circular reference errors, but I am uncertain about how to resolve it in this particular context.
- Example of a circular reference in Javascript?
- Detecting and fixing circular references in JavaScript
- Is circular reference between objects a bad practice?
Could someone assist me in retrieving the value of navigator.plugins
please?