Превышено время ожидания Mocha + Selenium - PullRequest
0 голосов
/ 11 февраля 2020

Я пытаюсь запустить мокко с селеном в проекте, созданном с помощью приложения Создать реагирование.

Когда я пытаюсь запустить тест, я получаю эту ошибку: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

Очевидно, Мне нужно где-то поставить "done ()". Но я не совсем уверен. Это действительно странный синтаксис, который я не могу понять. (Скопировано из документации)

var assert = require("assert");
const { By, until } = require("selenium-webdriver");
var webdriver = require("selenium-webdriver");
require("chromedriver"); // Application Server

var driver = new webdriver.Builder()
  .usingServer()
  .withCapabilities({ browserName: "chrome" })
  .build();

describe("The flag", () => {
  /**
   * Test case to load our application and check the title.
   */
  it("Should change by clicking on a smaller flag", () =>
    (async function login11() {
      const setUp = async driver => {
        await driver.get(url);
        // wait for the page to load
        await driver.wait(() =>
          driver.wait(
            until.elementLocated(
              By.xpath(`//*[@id="react-joyride-step-0"]/div/div/div/div/div[3]/button[1]`)
            ),
            3000
          )
        );
        //skip guide
        await driver
          .findElement(By.xpath(`//*[@id="react-joyride-step-0"]/div/div/div/div/div[3]/button[1]`))
          .click();
      };

      const logIn = async (driver, password = 11) => {
        // ...
      };

      const logout = async () => {
       // ...
      };
      const checkUserName = async () => {
       // ...
      };
      try {
        await setUp(driver);

        await driver.findElement(By.xpath(`//*[@id="root"]/div/div/div[2]/div/div[2]`)).click();
        await driver
          .findElement(By.xpath(`//*[@id="root"]/div/div/div[2]/div/div[2]/div[2]/ul/div[2]/li`))
          .click();
        const flagAfterChange = await driver.findElement(
          By.xpath(`//*[@id="root"]/div/div/div[2]/div/div[2]`)
        );
        expect(flagAfterChange).toEqual("DE");
        //await logout();

        // //click on more actions
        // await driver.findElement(By.xpath(`//*[@id="root"]/div/div/div[3]/div[10]`)).click();
      } finally {
        // await driver.wait(driver.quit(), 3000);
      }
    })());

  // afterAll(() => {
  //   // End of test use this.
  //   driver.quit();
  // });
});

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...