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

154
Visualizações
Can't seem to be able to bypass this error - "element not interactable"

So all I want to do is automate a login through WebdriverIO.

This is the LoginPage class where the error occurs, login function - "element not interactable"

class LoginPage {

  get inputUsername() {
    const username = $("#username");
    username.waitForClickable();
    return username;
  }

  get inputPassword() {
    const password = $("#current-password");
    password.waitForClickable();
    return password;
  }

  get btnSubmit() {
    const submitButton = $(".button.button--primary.button--l");
    submitButton.waitForClickable();
    return submitButton;
  }

  async login(username, password) {
    await this.inputUsername.setValue(username); //<--Throws error
    await this.inputPassword.setValue(password); //<--Throws error
    await this.btnSubmit.click(); //<--Not sure if throws error
  }

}

The parameters from the login function come from the call of it on the test file.

describe("login", () => {
  it("should successfully login", async () => {

    await browser.maximizeWindow();

    await LoginPage.open(); //<--Opens the login page on the browser

    await LoginPage.login(
      "emailtest@test.com",
      process.env.PASSWORD
    );

    await expect(browser).toHaveUrl(process.env.CLIENT_AREA_URL);
  }
}

I believe I'm using mocha for the test structure and for the reporters (spec and allure), correct me if I'm wrong in something.

I'm kinda new in Automated Web Testing, can someone help me on this?

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

0

It looks like waitForClickable doesn't work in this case. Could you move it to the async function?

Based on your code:

get inputUsername() {
  return $("#username");
}

async login(username, password) {
  await this.inputUsername.waitForClickable();
  await this.inputUsername.setValue(username);
  ...
}

wait... and set... can be moved to browser.addCommand() in wdio.conf to have a cleaner code.

about 4 years ago · Juan Pablo Isaza Relatório

0

Try this:

class LoginPage {

  get inputUsername() { return $("#username"); 
  get inputPassword() {return $("#current-password"); 
  get btnSubmit() {return $(".button.button--primary.button--l");

  async login(username, password) {

    await this.inputUsername.waitForClickable();
    await this.inputUsername.setValue(username); 
    await this.password.waitForClickable();
    await this.inputPassword.setValue(password); 
    await this.submitButton.waitForClickable();
    await this.submitButton.click(); 
  }
}

I would recommend to write even a method to fill the input:

async fillLoginName(loginname){

await this.inputUsername.waitForExist();
await this.inputUsername.clearValue();
await this.inputUsername.setValue(loginname);

}

and you called just in your test as:

it("should successfully login", async () => {

  await Loginpage.fillLoginName("emailtest@test.com");

   // do the rest for password field and click login button

)}
about 4 years ago · Juan Pablo Isaza Relatório

0

There are a couple things that could be causing this:

  • The page has a cookie "modal" window that pops up. This modal can block the text input into the login form, which is what the "element not interactable" message comes from. If this is the case, you'll also likely see an additional message saying another element received a click.
  • The login page loads content via JavaScript API calls. WebdriverIO/Selenium is good about waiting for normal page loads, but when you load content via JavaScript, it doesn't know to wait for that. You do have the username.waitForClickable(); calls, but I think they might need to be await username.waitForClickable();to work.
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