通过Webdriver IO在PhantomJS中运行自动化测试

Running Automation test in PhantomJS through Webdriver-IO

本文关键字:运行 自动化测试 PhantomJS Webdriver IO 通过      更新时间:2023-09-26

我一直试图在phantomjs上运行测试,直接通过mocha、wdio或gullow运行,但每次测试都会因超时错误而终止。尽管测试在chrome和firefox上运行得很好,但它只是在phantomjs中出现了一个错误。我已经在全球和我的项目中安装了phantomjs,但从过去两天起我就无法让它工作了。

这就是我测试的方法

before( function (done) {
    driver = webdriverio.remote({ desiredCapabilities: {
        browserName: 'phantomjs'
    } });
    driver.init(done);
});

链接到我的项目:https://github.com/anarwal/asg...

注意:我在windows上运行测试,这就是问题所在,它们在MAC 上运行良好

使用无头浏览器时,需要运行selenium服务器。

这里有一个很好地解释了使用javascript的例子。

您可能会发现Chimp.js很有用,因为它可以轻松地在本地使用Chrome或FF,但在服务器上使用PhantomJS。请参阅:http://chimpjs.com/

Chimp.js的工作原理是"无缝集成CucumberJS/Mocha、Selenium、WebdriverIO和Chai/Jasmine Expect,协同工作。它旨在消除设置这些工具时带来的所有痛苦,使其能够很好地协同工作…"-更多信息,请访问:https://chimp.readme.io/docs