Кукловод не работает правильно без головы: правда - PullRequest
0 голосов
/ 23 октября 2019

У меня есть тестовый пример, который выбирает публикацию из списка и нажимает на нее кнопку ретвита, чтобы вызвать модальный режим, который затем вставляется в DOM и имеет 2 кнопки: Подтвердить и Отменить.

В режиме без заголовка: false - все работаеткак и ожидалось, модальное отображается и щелкается: https://i.imgur.com/oDgFzxC.png

В режиме без головы: true - модальное никогда не открывается: https://i.imgur.com/KTQo91a.png

Тестовый код

test('should repost conversation', async () => {
    const options = {
      showOwnedBtn: 'showOwned-link',
      ideaSelector: 'searchbar-idea',
      retweetBtn: 'retweet-button',
      selectedPublication: 'The looming challenge to South Korea competitiveness',
      titleSelector: 'publicationTitle-link',
      repostBtn: 'repost-button',
    }
    await login.user(users.hubert, 'wubs', path);
    await navbar.removeFilter(options.showOwnedBtn, path);
    await navbar.searchFilter(options.ideaSelector, path, null);

    await publication.selectPublicationRetweetByTitle(options.titleSelector, options.selectedPublication, path);
    await page.waitForSelector(options.repostBtn)
    await modal.confirm(options.repostBtn, path);

    await navbar.goto('flow', path);

    await screenshot.take(path);
    await logout.user(users.hubert, 'wubs', path);
  });

Проблемный метод:

async selectPublicationRetweetByTitle(selector, text, path) {
    const retweetSelector = dataAutomation('retweet-button');
    const pub = dataAutomation('publication')
    const publicationSelector = await page.$$(pub);
    let selected = null;
    for (const publication of publicationSelector) {
      const pubTitleSelector = await publication.$('[data-automation="publicationTitle-link"]');
      const pubTitle = await pubTitleSelector.getProperty('innerText');
      const titleText = await pubTitle.jsonValue();
      if (titleText === text){
        selected = await publication.$(retweetSelector);
      }
    }
    await screenshot.take(path);
    await selected.click();

    await screenshot.take(path);
  }
...