Google Slides has a option under tools >> Linked Objects called "Update all":
This option updates all elements in the Presentation. Something similar can be done with Google App Scripts, but unfortunately it does not update tables, it only updates charts. So this solution and other similar workarounds do not work for my project.
I have used Selenium to automate some tasks in other websites, but the elements in Google Slides apparently change their values dynamically. So I could not use something like:
tool_menu = wd.find_element(By.CSS_SELECTOR, 'menu.tool')
tool_menu.click()
Is there a way to navigate to Linked Objects and click on Update all using Selenium?
EDIT:
After some back and forward with a very helpful user, this is the final working code:
# Stuff to make this run on google Colab
!pip install selenium
!apt-get update # to update ubuntu to correctly run apt install
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver')
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
wd = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
wd.get("https://docs.google.com/presentation/d/[id]/")
from IPython.core.display import Image, display
file_name = "part.png"
wd.set_window_size(1920,1080)
wd.get_screenshot_as_file(file_name)
display(Image(file_name))
# open Tools menu
wd.find_element(By.ID,'docs-tools-menu').click()
time.sleep(1) #this is not optimal, you should use explicit waiters
wd.get_screenshot_as_file(file_name)
display(Image(file_name))
menus = wd.find_elements(By.XPATH, '//div[@role="menu"]')
menu = None
# loop through menus to find the visible one
for m in menus:
if m.is_displayed():
menu = m
break
assert menu
# select the menu item
menu_label = "Linked objects" #change according to you language
item = menu.find_element(By.XPATH,'//span[contains(@aria-label, "%s")]' % menu_label)
item.click()
time.sleep(3) #this is not optimal, you should use explicit waiters
wd.get_screenshot_as_file(file_name)
display(Image(file_name))
# ------- I would use this
refresh_label = "Refresh" # change according to your language (see DOM for the correct label)
refresh_btn = wd.find_element(By.XPATH,'//div[contains(@aria-label, "%s")]' % refresh_label)
# --------
refresh_btn.click()
time.sleep(3)
wd.get_screenshot_as_file(file_name)
display(Image(file_name))
#select update all button
update_all_btn = wd.find_element(By.XPATH,'//div[contains(@class, "update-all-button")]')
update_all_btn.click()