Matheus Campos
Matheus Campos

Reputation: 37

Selenium wait and click using nodejs

I'm trying to login on fifa ultimate team... but i don't know why if i try to use wait the click action did not anything... basicly my url is https://www.easports.com/fifa/ultimate-team/web-app/ and the button i need to click is Login any idea?

require('chromedriver');
const webdriver = require('selenium-webdriver');

var until = webdriver.until;
var By = webdriver.By;

async function myMain(){

    let driver = new webdriver.Builder().forBrowser('chrome').build();
    await driver.get('https://www.easports.com/fifa/ultimate-team/web-app/');
    await driver.wait(until.elementLocated(By.className('btn-standard call-to-action')), 15000);
    await driver.findElement(By.className('btn-standard call-to-action')).click();
}

myMain();

Upvotes: 1

Views: 2846

Answers (1)

CEH
CEH

Reputation: 5909

Your selector might not be quite right. Try this:

  await driver.wait(until.elementLocated(By.xpath("//button[text()='Login']")),15000);
  let loginButton = driver.findElement(By.xpath("//button[text()='Login']"));

  await driver.wait(until.elementIsEnabled(loginButton ,15000));

  await driver.findElement(By.xpath("//button[text()='Login']")).click();

Upvotes: 1

Related Questions