Featured image of post Python selenium solves the problem that chrome://settings cannot be located

Python selenium solves the problem that chrome://settings cannot be located

Great God answers:

stackoverflow-56763683

stackoverflow-56380091

Implementation example

  1. Clear browsing history button
1
return document.querySelector('settings-ui').shadowRoot.querySelector('settings-main').shadowRoot.querySelector('settings-basic-page').shadowRoot.querySelector('settings-section > settings-privacy-page ').shadowRoot.querySelector('settings-clear-browsing-data-dialog').shadowRoot.querySelector('#clearBrowsingDataDialog').querySelector('#clearBrowsingDataConfirm')
  1. Added sound button
1
return document.querySelector('settings-ui').shadowRoot.querySelector('settings-main').shadowRoot.querySelector('settings-basic-page').shadowRoot.querySelector('settings-privacy-page').shadowRoot .querySelector('settings-animated-pages > settings-subpage > category-setting-exceptions').shadowRoot.querySelector('site-list').shadowRoot.querySelector('#addSite')
  1. Added sound button
1
return document.querySelector('settings-ui').shadowRoot.querySelector('settings-main').shadowRoot.querySelector('settings-basic-page').shadowRoot.querySelector('settings-privacy-page').shadowRoot .querySelector('settings-animated-pages > settings-subpage > category-setting-exceptions').shadowRoot.querySelector('site-list').shadowRoot.querySelector('add-site-dialog').shadowRoot.querySelector( '#site').shadowRoot.querySelector('#input')
  1. Added sound confirmation button
1
return document.querySelector('settings-ui').shadowRoot.querySelector('settings-main').shadowRoot.querySelector('settings-basic-page').shadowRoot.querySelector('settings-privacy-page').shadowRoot .querySelector('settings-animated-pages > settings-subpage > category-setting-exceptions').shadowRoot.querySelector('site-list').shadowRoot.querySelector('add-site-dialog').shadowRoot.querySelector( '#add')

##Python:

1
2
3
clearButton = browser.execute_script("return document.querySelector('settings-ui').shadowRoot.querySelector('settings-main').shadowRoot.querySelector('settings-basic-page').shadowRoot.querySelector('settings- privacy-page').shadowRoot.querySelector('settings-animated-pages > settings-subpage > category-setting-exceptions').shadowRoot.querySelector('site-list').shadowRoot.querySelector('#addSite')" )
#click on the clear button now
clearButton.click()
Built with Hugo
Theme Stack designed by Jimmy