I am trying to create a script that downloads my tableau public viz and sends it to me. It is for a project. I keep running into problems after I click on the download button
from seleniumbase import BaseCase
import pyautogui
class Test(BaseCase): def test_basic(self): # Open Tableau page self.open("https://public.tableau.com/app/discover/viz-of-the-day") self.maximize_window()
# Wait for page to load
self.wait_for_ready_state_complete()
# Click on the first visualization
self.click("ul._galleryList_1hb88_2 li:first-child a")
# Wait for page to load
self.wait_for_ready_state_complete()
self.sleep(2)
self.click("//*[@id='root']/div/div[4]/div[1]/div/div[2]/button[4]")
self.sleep(5)
pyautogui.press('enter')
self.sleep(5)
BaseCase.main(name, file)
This works but it only allows me to download the dashboard as a png.
I tried using the code below to help going down to the pdf but it doesn't work.
from seleniumbase import BaseCase
import pyautogui
class Test(BaseCase): def test_basic(self): # Open Tableau page self.open("https://public.tableau.com/app/discover/viz-of-the-day") self.maximize_window()
# Wait for page to load
self.wait_for_ready_state_complete()
# Click on the first visualization
self.click("ul._galleryList_1hb88_2 li:first-child a")
# Wait for page to load
self.wait_for_ready_state_complete()
self.sleep(2)
self.click("//*[@id='root']/div/div[4]/div[1]/div/div[2]/button[4]")
self.sleep(5)
pyautogui.press('tab')
self.sleep(5)
pyautogui.press('tab')
self.sleep(5)
pyautogui.press('tab')
self.sleep(5)
pyautogui.press('enter')
self.sleep(5)
BaseCase.main(name, file)
This downloads the PDF of the first chart displayed:
There's a
breakpoint()at the end to pause the script with the browser window still open. Typecand pressEnterto continue from the breakpoint. Adjust timing as needed. This should be enough to get you started on the right path.