Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
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 Respuestas
Responde la pregunta

0

Can you try below code

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

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda