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

117
Visualizações
RobotFramework - Execute Javascript

I'm trying to inject my browser with JavaScript Executor function to get back into running instance of a browser. For it, I'm using the keyword "Exectute JavaScript" My code looks like this:

SeleniumLibrary.Execute Javascript           JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("alert('OK')")

Error looks like this:

JavascriptException: Message: javascript error: Unexpected identifier

(Session info: chrome=92.0.4515.107)

It looks like import for JavaScriptExecutor? How can this be done?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Can you try below code

SeleniumLibrary.Execute Javascript   alert('OK')
about 4 years ago · Juan Pablo Isaza Relatório

0

The alert should be handled with the Handle Alert keyword as you seem to have done already. For returning to earlier browser instance Selenium provides two entities which can be used. You may want to see the Browsers and Windows section of the SeleniumLibrary documentation.

Basic use case is that when opening browser, you'll give it an alias and then use Switch Browser to get back to that browser instance. Within that browser you may have multiple pages open, they can be accessed with normal locators by using Switch Window keyword. For example I would commonly use the window URL as that tends to have at least some unique part in it. If none of the URL, title, or name are unique, by using keyword Get Window Handles returns a list of windows within that browser. In your case, expecting no other windows are opened during the test, the main browser window can be found with argument MAIN.

You may consider this incomplete example and fill in your specifics which you did not provide in the question.

Test 1
    Open Browser    ${your URL}    alias=browser1
    # Do whatever triggers the alert
    Handle Alert
    Switch Window    MAIN
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