Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: Selenium Grid - AttributeError: 'WebDriver' object has no attribute 'execute_cdp_cmd' #1844

Closed
SanjaySRocks opened this issue Aug 7, 2024 · 2 comments
Labels
bug Something isn't working needs-triaging

Comments

@SanjaySRocks
Copy link

What happened?

Using docker selenium/standalone-chrome container

I have this function in my python script which saves html to pdf file and it works fine with selenium locally.

When I use it with selenium grid remotely it throws an error:

 result = self.driver.execute_cdp_cmd("Page.printToPDF", print_options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'WebDriver' object has no attribute 'execute_cdp_cmd'
def save_as_pdf(self, path):
        directory = os.path.dirname(path)
        if not os.path.exists(directory):
            os.makedirs(directory)

        print_options = {
            'landscape': False,
            'displayHeaderFooter': False,
            'printBackground': True,
            'preferCSSPageSize': True
        }

        # Convert the page to PDF
        result = self.driver.execute_cdp_cmd("Page.printToPDF", print_options)
        
        # Decode the base64-encoded PDF data
        pdf_data = base64.b64decode(result['data'])
        
        # Write the PDF to a file
        with open(path, 'wb') as file:
            file.write(pdf_data)

What browsers and operating systems are you seeing the problem on?

Chrome Browser and Ubuntu Operating System

@SanjaySRocks SanjaySRocks added bug Something isn't working needs-triaging labels Aug 7, 2024
Copy link
Contributor

github-actions bot commented Aug 7, 2024

@SanjaySRocks, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol
Copy link
Member

diemol commented Aug 8, 2024

Please create this issue at https://github.com/SeleniumHQ/selenium, and fill out the whole template.

@diemol diemol closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triaging
Projects
None yet
Development

No branches or pull requests

2 participants