Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Uses Selenium to delete every topic in a Google Group (rate of around 2k/hour deletions)
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import as ui
from import By
from import expected_conditions as EC
credentials = {
# login credentials for google group
'username': '<username>',
'password': '<password>',
# name of the group
'group_name': '<group_name>',
def delete_everything(driver):
# Open the main window
wait = ui.WebDriverWait(driver, 10)
driver.get('' + credentials['group_name'] + '&hl=en&service=groups2')
# Login
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[type="email"]')))
username = driver.find_element_by_css_selector('input[type="email"]')
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[type="password"]')))
password = driver.find_element_by_css_selector('input[type="password"]')
# =============
# =============
deleted = True
while (deleted):
deleted = False
# Choose a topic
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div[role="listitem"]')))
topic = driver.find_element_by_css_selector('div[role="listitem"]')
if topic:
# Open actions
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div[data-title="Actions"]')))
actions_button = driver.find_element_by_css_selector('div[data-title="Actions"]')
# Choose delete
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#ma_DELETE_TOPICS')))
delete_option = driver.find_element_by_css_selector('#ma_DELETE_TOPICS')
# Choose 'Other' option
wait.until(EC.element_to_be_clickable((By.XPATH, "//label[contains(text(), 'Other')]")))
other_option = driver.find_element_by_xpath("//label[contains(text(), 'Other')]")
other_option_parent = other_option.find_element_by_xpath("..")
radio = other_option_parent.find_element_by_css_selector('span[role="radio"]')
# Submit delete request
deleted = True
finished = False
while not finished:
driver = webdriver.Chrome('./chromedriver') # Download from
finished = True
except Exception as e:
print e
finished = False
time.sleep(5) # Wait 5 seconds, and go again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.