mardi 11 février 2020

I don't understand what is the problem with this 2 functions

  it('should change comment status to SOLVED',
    async function() {
      await page.click("#view_replies3");
      await change_comment_status(page, 5, 'SOLVED');
      expect(await page.content())
        .to.include('comm1')
        .to.include('"timeline-comment-status bg-success" name="5"');

      var comment_ids = await page.$$eval('li.timeline-comment',
        elements => elements.map((element) => element.getAttribute('name')));
      var comment_statuses = await page.$$eval(
        'input.custom-control-input',
        elements => elements.map((element) => element.checked)
      );
      expect(comment_ids).to.deep.equal(['1', '3', '5', '7', '6', '4']);
      expect(comment_statuses).to.deep.equal(
        [true, false, true, false, false, false]
      );
  }).timeout(0);
async function change_comment_status(page, comment_id, status) {
  const selector = "input.custom-control-input[name='" +
    comment_id.toString() + "']";
  page.waitForSelector(selector);

  await page.evaluate(selector => {
    let element = document.querySelector(selector);
    element.click();
  }, selector);
}

I am getting this error: https://pastebin.com/Gb60DJ5V After I tried:

async function change_comment_status(page, comment_id, status) {
  const selector = "input.custom-control-input[name='" +
    comment_id.toString() + "']";
  page.waitForSelector(selector);

  await page.evaluate(selector => {
    let element = document.querySelector(selector);
    console.log(element);
    element.click();
  }, selector);

I get this error: 'Cannot find context with specified id undefined'.

Any ideas? Thanks, guys!

Aucun commentaire:

Enregistrer un commentaire