Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda