0

我有一个测试用例,它从列表中选择发布并单击其上的转发按钮以触发模式,然后将其插入 DOM 并具有 2 个按钮,确认和取消。

在 headless: false - 一切都按预期工作,显示并单击模式: https ://i.imgur.com/oDgFzxC.png

在 headless: true - modal 永远不会打开: 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);
  }
4

0 回答 0