1

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();

1 Answer 1

1

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();
Sign up to request clarification or add additional context in comments.

6 Comments

thanks for answer. I tried and get that message: UnhandledPromiseRejectionWarning: NoSuchElementError: no such element: Unable to locate element: {"method":"xpath","selector":"//button[text()='Login']"} Because the element take some seconds to load... Did you tried on your browser?
My apologies, my solution did not take the initial long loading time into account. I've updated my answer accordingly.
no problems... I got that error "TypeError: element.isDisplayed is not a function" in await driver.wait line... any idea?
element.isDisplayed is meant to take an existing WebElement, while elementVisible takes By as parameter. Updated my example to use elementVisible instead, and added additional wait on elementIsEnabled.
thank you soo much!!! it works!!! you only need to add an ) after loginButton ,15000
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.