I want to zoom to a pdf that was uploaded to google. I try changing the 100% to 200% or other percentage, but the problem I have is that they are not buttons, but icons.
How do I zoom to the pdf?
I want to zoom to a pdf that was uploaded to google. I try changing the 100% to 200% or other percentage, but the problem I have is that they are not buttons, but icons.
How do I zoom to the pdf?
This sis a bit hacky but i could not find a better solution for this:
what it does is to set the zoom level of the whole browser. you can check the zoom levels in the browser settings. e.g. 1.25 or 1.5.
def set_zoom(zoom = 1):
current_tab_index = driver.window_handles.index(driver.current_window_handle)
driver.execute_script("window.open('');")
driver.switch_to.window(driver.window_handles[-1])
driver.get('chrome://settings/')
print(current_tab_index)
def expand_shadow_element(element):
shadow_root = driver.execute_script('return arguments[0].shadowRoot', element)
return shadow_root
# process to set zoom level of browser
root1=driver.find_element_by_xpath("*//settings-ui")
shadow_root1 = expand_shadow_element(root1)
container= shadow_root1.find_element_by_id("container")
root2= container.find_element_by_css_selector("settings-main")
shadow_root2 = expand_shadow_element(root2)
root3=shadow_root2.find_element_by_css_selector("settings-basic-page")
shadow_root3 = expand_shadow_element(root3)
basic_page = shadow_root3.find_element_by_id("basicPage")
settings_section= basic_page.find_element_by_xpath(".//settings-section[@section='appearance']")
root4= settings_section.find_element_by_css_selector("settings-appearance-page")
shadow_root4=expand_shadow_element(root4)
settings_animated_pages= shadow_root4.find_element_by_id("pages")
zoom_select = settings_animated_pages.find_element_by_id("zoomLevel")
zoom_select.find_element_by_css_selector(f"option[value='{zoom}']").click()
driver.close()
driver.switch_to.window(driver.window_handles[current_tab_index])
driver.refresh()
code inspired by this answer here: https://stackoverflow.com/a/47086145/11699898