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

376
Views
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 answers
Answer question

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 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!