Utilizing SelenuimBase to fetch a Tableau dashboard for downloading

I have been working on a script to automate the download of my Tableau Public visualization for a project. However, I am facing issues after clicking 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)

Although this solution only downloads the dashboard as a png, it works successfully.

To attempt downloading as a PDF, I tried modifying the code below, but faced difficulties:

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)

Answer №1

To begin, initiate the PDF download of the initial chart presented:

from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)

class TableauTest(BaseCase):
    def test_tableau_pdf_download(self):
        self.open("https://public.tableau.com/app/discover/viz-of-the-day")
        self.click('img[alt="Workbook thumbnail"]')
        self.sleep(4)
        self.click('button[data-tip="Download"]')
        self.sleep(1)
        self.switch_to_frame('iframe[title="Data Visualization"]')
        self.click('button[data-tb-test-id="DownloadPdf-Button"]')
        self.click('button[data-tb-test-id="export-pdf-export-Button"]')

        breakpoint()

At the conclusion, there is a breakpoint() to halt the script while the browser window remains open. Input c and hit Enter to continue past the breakpoint. Adjust timing if necessary. This should provide a solid starting point for your journey.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Displaying a variable in a live HTML user interface

I have successfully created a Python program that captures data from an Arduino Potentiometer and shows it on the Python console. Now, I am working on enhancing the output by displaying it in a local HTML file. I am seeking guidance on how to incorporate t ...

Integrating Python Script with User Input and Output within a JavaScript Web Application

I have an existing JS website that requires additional functionality, and after some research I believe Python is the best tool to handle the necessary calculations. My goal is for users to input information that will then be used as input for my Python ...

Is it possible to achieve compatibility between Python and PHP in web development?

I am currently engaged in a legacy PHP project that relies heavily on PHP for its backend operations. However, I have a strong interest in scripting and developing fun and useful features using Python. My question is: Is there a way to incorporate Python ...

Encountering a FileNotFoundError while attempting to automate responses to a Google form using Selenium and WebDriver

Looking to automate responses on a Google Form using Selenium, following this model: youtu.be/BvU7qfdrqjc (25 sec video); more details can be seen in this video: youtu.be/MUxScr-p-jl. While testing the code, an error cropped up: Code: from selenium impor ...

Create hough transformation lines on top of a photo

Trying to implement the Hough line transform independently has proved challenging, particularly when it comes to drawing the high-voted thetas/rhos values. Despite attempting the mathematical calculations myself, the outputs were consistently inaccurate. U ...

Click on a previously saved Selenium element once the page has been reloaded

Is there a way to achieve a similar functionality where each "button" press triggers a page reload? element = driver.find_element_by_xpath("//select[@name='name']") all_options = element.find_elements_by_tag_name("option") for option in all_opti ...

Is there a way to efficiently download a large number of images (70,000) from URLs while adhering to restrictions on simultaneous downloads

I'm feeling a bit lost here. I have this csv file containing two columns: name and picture URL. My goal is to bulk download the 70k images from the file and save them in a folder, renaming each image with the corresponding name from the first column. ...

Python's List Comprehension Outperforms Selenium While Loops

I've been on a wild expedition through the depths of the internet in search of an answer to this particular enigma, but my efforts have been in vain so far. Currently, I'm attempting to extract data from the last four pages of last.fm entries fo ...

What could be causing my write() function to output an empty text file instead of the expected content? - web scraping issue

I am encountering an issue where my code is generating a blank text file instead of populating it with the expected items. When I run the script in Anaconda, the text is successfully printed inside the file which leads me to believe that the problem lies w ...

Putting the database on ice to experiment with new functionalities in Django

I am looking to incorporate a few additional fields into the existing models of my Django app and potentially create a new class. My goal is to test this new feature and ensure that it functions properly. While I can easily revert the code changes using g ...

Using Selenium in Python to interact with and click a span element

For days, I have been attempting to use Selenium with Python to click on the continue button in the Login Page from the provided link below: Despite trying various selectors like xpath, nothing seems to be working for me. This is the specific element tha ...

Generate Python variables from a text file

Connected to this question is where I found guidance. Attempting to implement the solution presented in the first answer, I made adjustments to the code but encountered issues due to the presence of "[]" symbols in the variables. A text file is provided b ...

Using selenium to iterate through previous results and accumulate them in a for loop

My code is functioning, but it seems to be accumulating the previous results. Can someone please assist me with this issue? Thank you. url=https://www.bbc.com/news/world news_search = driver.find_elements(By.XPATH, "//div[@class='gs-c-promo gs-t ...

What is the importance of using time.sleep in Python Selenium Webdriver when locating elements by XPath?

Recently, I encountered a peculiar situation while attempting to scrape a webpage using Python selenium webdriver. It seems that when I use the find_element_by_xpath method without including time.sleep, I am unable to retrieve any information. However, as ...

Just getting started with the selenium package, experimenting with entering login information

Hello everyone, I need some input to help me troubleshoot an issue I'm having with my code. I am trying to log in to a specific website using Selenium, but I keep encountering this error message: An Exception has occurred: AttributeError 'list ...

Is there a way to display a list of dropdown menu options using Selenium with Python?

I am currently attempting to utilize Selenium Python and its PhantomJS function in order to print out all the items from the first drop-down menu on this particular page (). Unfortunately, I keep encountering a No Attribute error message. If anyone could ...

What to do when encountering AttributeError: The 'Web3' object does not have the attribute 'toChecksumAddress'?

Currently, I'm exploring the usage of 1inch oracle methods available on this repository. The python wrapper around 1inch APIs seems to be a helpful resource for fetching token prices using oracle method "get_rate_to_ETH". Despite trying to implement ...

Creating a Copy of HdrHistogram's HistogramPlotter Display

I am experimenting with reproducing the HistogramPlotter output using pandas and matplotlib. The output from the link provided has this appearance: https://i.stack.imgur.com/OlBAs.png However, my current script's output is noticeably more compressed ...

Load user information for the current logged in user using Django

Greetings fellow Django beginners! I know this question has been asked before, but I'm having trouble finding a solution that fits my specific situation. Here's the issue: I have a Form with a choice field that gets its options from the databas ...

A python script designed to retrieve URLs from a webpage

Trying to download an entire playlist for Android development tutorials from YouTube can be quite a task. The use of savefrom.net helped in generating the playlist for download, but facing the issue of handling numerous videos in the playlist. To simplify ...