Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
How to select this element (in Python)

I'm attempting to get a selector on this action-button class using Selenium in Python, but through using a Javascript Document QuerySelector. That means executing some js code via the WebDriver, which looks something like this:

    printBtnlast = driver.execute_script(
                "return document.querySelector('print-preview-app')...('controls').querySelector({WHAT_TO_DO_HERE?})"
    )

(abridged with '...' to show the main idea)

So far I have tried the query: 'cr-button[class='action-button']', which surprisingly gives a Message: javascript error: missing ) after argument list.

What can I place in {WHAT_TO_DO_HERE?} in order to access the action-button in the image below?

Final Div

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

for this

  printBtnlast = driver.execute_script(
                "return document.querySelector('print-preview-app')...('controls').querySelector({WHAT_TO_DO_HERE?})"
    )

You can try this :

printBtnlast = driver.execute_script("return document.querySelector('div.controls > cr-button.action-button')")

or

printBtnlast = driver.execute_script("return document.querySelector('cr-button.action-button')")
about 4 years ago · Juan Pablo Isaza Report

0

query Selector syntax is a little bit different than XPath syntax. You can use CSS Selectors to locate an element. One way to find the button:

querySelector("cr-button.action-button")

I don't have access to the page since you didn't provide, but it may be the case that there are more than one elements with the given path. Then other solution might be:

querySelector("div.controls > cr-button.action-button")

The query you tried may give an error due to the quotation marks. You can try this:

'cr-button[class="action-button"]'

This should work:

printBtnlast = driver.execute_script("return document.querySelector('.controls > .action-button')")
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!