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

377
Vistas
Why am I getting the error java.lang.IllegalArgumentException: Argument is of an illegal type: org.openqa.selenium.By$ByXPath

i want to press a key with JavascriptExecutor.For this I have created a class and a static method.

    private static JavascriptExecutor jsExecutor = (JavascriptExecutor)BrowserFactory.getDriver();

public static void clickButton(BaseElement element){
    jsExecutor.executeScript("arguments[0].click()", element.getLocator());
}

But when in my PageObject method I call the button click, I get an error

    public void clickForJsAlertButton() {
    ScriptManager.clickButton(elementButton);
}

java.lang.IllegalArgumentException: Argument is of an illegal type: org.openqa.selenium.By$ByXPath

I do not understand why this is happening and what needs to be done to fix it

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

jsExecutor - only works with WebElement

    public static void clickButton(By locator){
    WebElement element = BrowserFactory.getDriver().findElement(locator);
    jsExecutor.executeScript("arguments[0].click()", element);
}
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