daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. opt = webdriver.ChromeOptions()
  2. opt.add_extension("Block-image_v1.1.crx")
  3. browser = webdriver.Chrome(chrome_options=opt)
  4.    
  5. chromeOptions = webdriver.ChromeOptions()
  6. prefs = {"profile.managed_default_content_settings.images":2}
  7. chromeOptions.add_experimental_option("prefs",prefs)
  8. driver = webdriver.Chrome(chrome_options=chromeOptions)
  9.    
  10. driver = webdriver.Chrome()
  11.  
  12.  
  13. def expand_shadow_element(element):
  14.   shadow_root = driver.execute_script('return arguments[0].shadowRoot', element)
  15.   return shadow_root
  16.  
  17. driver.get("chrome://settings")
  18. root1 = driver.find_element_by_tag_name('settings-ui')
  19. shadow_root1 = expand_shadow_element(root1)
  20.  
  21. root2 = shadow_root1.find_element_by_css_selector('[page-name="Settings"]')
  22. shadow_root2 = expand_shadow_element(root2)
  23.  
  24. root3 = shadow_root2.find_element_by_id('search')
  25. shadow_root3 = expand_shadow_element(root3)
  26.  
  27. search_button = shadow_root3.find_element_by_id("searchTerm")
  28. search_button.click()
  29.  
  30. text_area = shadow_root3.find_element_by_id('searchInput')
  31. text_area.send_keys("content settings")
  32.  
  33. root0 = shadow_root1.find_element_by_id('main')
  34. shadow_root0_s = expand_shadow_element(root0)
  35.  
  36.  
  37. root1_p = shadow_root0_s.find_element_by_css_selector('settings-basic-page')
  38. shadow_root1_p = expand_shadow_element(root1_p)
  39.  
  40.  
  41. root1_s = shadow_root1_p.find_element_by_css_selector('settings-privacy-page')
  42. shadow_root1_s = expand_shadow_element(root1_s)
  43.  
  44. content_settings_div = shadow_root1_s.find_element_by_css_selector('#site-settings-subpage-trigger')
  45. content_settings = content_settings_div.find_element_by_css_selector("button")
  46. content_settings.click()
RAW Paste Data
Top