使用Mocha暂停硒中的iframe

时间:2019-09-07 00:40:49

标签: javascript asynchronous iframe mocha chai

我正在尝试将摩卡咖啡与selienum一起使用,而不是暂停iframe。

我已经将驱动程序集中在框架上,并且我可以使它正常运行。但是当我暂停时,什么也没发生。

const { assert, equal } = require('chai');

let mochaAsync = (fn) => {
    return (done) => {
      fn.call().then(done, (err)=>{
          console.log(err)
          done(err)
        });
    };
  };

describe('Check that script has recorded a play event', function() {

    const driver = new Builder().forBrowser('chrome').build();

    it('Should play the first video and register that it has started than stopped', mochaAsync( async function() {

        await driver.get('mysitetotest');
        await driver.wait(until.elementLocated(By.id('video-1')));
        await driver.sleep(1000)
        await driver.switchTo().frame(0)
        await driver.findElement(By.xpath("html/body")).click();
        await driver.sleep(2000)
        await driver.findElement(By.xpath("html/body")).click();
        await driver.switchTo().defaultContent()
        await driver.sleep(2000)
    }))
    after(async () => driver.quit());
});

0 个答案:

没有答案