Tag: webdriver io

如何将对象parameter passing给browser.execute方法?

我正在尝试使用WebdriverIO的execute方法传递一个浏览器对象,如下所示: describe('reference', () => { it('test browser', () => { browser.execute(function(){ console.log('BROWSER:', browser); }); }); }); 但是有一个错误: 失败:未知错误:未定义浏览器 我如何将浏览器对象传递给自定义函数?

如何build立一个节点模块?

我认为这将是微不足道的,我意识到它可能会有所不同,从项目到项目,但我试图重现本地webdriverio的节点模块构build,并在我的项目中使用。 这是我的尝试: git clone git@github.com:webdriverio/webdriverio.git cd webdriverio git checkout v4.8.0 npm install npm run build npm pack 这会产生一个名为webdriverio-4.8.0.tgz的文件。 我改变我的项目的package.json文件,以取决于这个文件,而不是从npm webdriverio 。 像这样: "webdriverio": "file:../webdriverio/webdriverio-4.8.0.tgz", 在我的项目中运行npm install ,按照预期更新node_modules webdriverio ,但我的版本与npm版本不同,尽pipe可能基于相同的代码。 我从来没有build立过一个节点模块,所以我很欣赏我可能错过了一些东西,但是我在网上find的资源似乎表明上面的应该足够了。 另外,如果有更好的方法来完成我想要完成的任务,我会很感激反馈。

WebdriverJS / IO&PhantomJS – 使用属性select器的Click处理程序不能与PhantomJS一起使用

我目前正在用WebdriverJS和PhantomJS编写一个应用程序testing套件。 为了确保我的testing工作,我首先通过Chrome运行它们,并且它们都正常工作。 当我换出PhantomJS的Chrome时,testing会中断。 这个问题 – WebDriver PhantomJS无法find元素,但与Firefox工作正常似乎概述了一个非常类似的问题,但附带的解决scheme似乎没有帮助。 下面是一个在Chrome上可以使用的types的简单例子,但不是PhantomJS上的例子: var client = webdriverjs.remote({ desiredCapabilities: { browserName: 'chrome' }, logLevel: 'silent' }); client.waitForExist("[data-id='1568911']", function(e){ client.click("[data-id='1568911']", function(e){ assert(!e, "Should click on a specific element:" + element); }); }); 在PhantomJS上运行时,我显然首先更改WebdriverJS选项: var client = webdriverjs.remote({ desiredCapabilities: { browserName: 'phantomjs', 'phantomjs.binary.path': "path/to/phantomjs" }, logLevel: 'silent' }); 但是当我运行testing并将logLevel设置为“详细”时,我收到如下所示的错误消息: [12:43:34]: COMMAND POST "/wd/hub/session/eb2b0a4b-e659-4607-bec0-82209bd6539a/element" […]

selenium独立与CORS

我目前正在通过nodejs与selenium独立使用webdriver io,这一切工作正常,直到我尝试做基于CORS的请求。 我目前使用Firefox作为testing浏览器,并且由于CORS请求到另一个域而引发错误。 服务器configuration为返回CORS的正确标题,XHR对象configuration为允许CORS。 我知道这些工作,因为当我手动使用该网站通过Firefox /铬的工作正常,但是当我testing它似乎炸毁了,这使我困惑,因为服务器和客户端configuration为CORS,并没有涉及当前testing的HTTPS。 那么为了让CORS在testing浏览器中工作,还有什么特别的事情要做吗? 我知道Selenium以自己的configuration文件启动浏览器,但是在configuration浏览器设置时找不到与cors有关的任何细节,也找不到与CORS实现相关的任何dependentFeatures。 如果能提供答案,我很乐意提供更多信息。

我如何使用wdio.conf.js?

我试图用jasminetesting框架webdriverio 。 我可以通过在命令行键入jasmine来运行我的testing。 但是,当我做wdio wdio.conf.js ,会打开一堆额外的浏览器,这些浏览器什么都不做。 我只是想知道wdio.conf.js文件是什么时候可以在命令行运行茉莉花。 最终它是一回事,对吧? 但是,我不能让wdio.conf.js文件以相同的方式工作,所以对我来说没用。 也许我没有正确地pipe理浏览器客户端,但是我没有看到关于如何通常完成的任何指导。 我读了文档,但它超出了自动生成wdio.conf文件的含义,所以“一切正常”。 我是否应该使用grunt或gulp来运行我的testing,或者将这些工具与wdio.conf的想法分开? 我只是试图让我的头在所有这些不同的工具。 我需要做的就是进行多个自动化testing来testing一个网站。 谢谢你的帮助。

运行cucumberjs ft。selenium,phantomjs,webdriverio时出错

我已经在全球安装了phantomjs npm install -g phantomjs 用java -jar selenium-standalone-2.52.0.jar启动selenium 像这样正确configurationcucumber的World对象: var options = { //desiredCapabilities: { browserName: 'internet explorer' }, // WORK //desiredCapabilities: { browserName: 'chrome' }, // WORK desiredCapabilities: { browserName: 'phantomjs' }, // NOT WORK waitforTimeout : 2000, host: '127.0.0.1', port: 4444 }; this.browser = webdriverio.remote(options); 它与Chrome&IE一起工作,但幻灯片失败。 这是我从Selenium控制台得到的错误: 错误 – org.apache.commons.exec.ExecuteException:执行失败(退出值:-559038737。由java.io.IOException引起:无法运行程序“C:\ Program Files(x86)\ nodejs […]

如何在webdriver.io中以32位模式启动IE

我正在使用gulp-wdio npm pakage在selenium独立上运行WebDriver.iotesting 我运行的代码是: gulp.task('e2e', function () { return gulp.src('wdio.conf.js') .pipe(wdio({ wdio: { specs: './test/features/**/*.feature' } })); }); 而我的wdio.conf.js这样定义浏览器: capabilities: [ { browserName: 'internet explorer', version: 'ANY' } ], 如何打字很慢 ,我在互联网上发现运行32位版本的networking驱动程序解决了这个问题,我怎么也找不到如何configurationfunction或其他地方来运行IE32位驱动程序默认情况下…任何帮助将不胜感激@ 🙂

我如何使用wdio.conf.js文件来指定哪些e2etesting运行的testing文件夹?

我有一个运行在各种不同模式的应用程序。 这些模式完全改变了用户界面,因此每种模式都需要一套完全不同的E2Etesting。 我为每个模式创build了不同的wdioconfiguration文件,并试图为每个模式指定规格,以便它只运行指定的规格。 不幸的是,这是行不通的。 所以现在有三个wdio.conf文件(所有这些文件都是从wdio.conf.js中inheritance的)以及下面的文件夹结构: +–test +–specs +–browser +–modeA +–testFile.js +–modeB +–testFile.js +–wdio.conf.js | +–wdio.conf.modeA.js | +–wdio.conf.modeB.js 我为每个模式创build了npm命令,如下所示: // (package.json) … "tools:e2e": "./node_modules/.bin/wdio wdio/wdio.conf.js", "tools:e2e:modeA": "./node_modules/.bin/wdio wdio/wdio.conf.modeA.js", "tools:e2e:modeB": "./node_modules/.bin/wdio wdio/wdio.conf.modeB.js", … 好的,所以在每个wdio.conf文件中,我指定了一些可能在每种不同模式下都改变的variables(这两个variables都是从wdio.confinheritance的),但是我想更改运行的文件,基本上只指定我只想运行当我运行npm run tools:e2e:modeA ,在modeA的文件夹中的文件,只运行modeB的文件,当我运行npm run tools:e2e:modeB 。 我试图通过在每个conf文件中定义规格来完成这个工作,如下所示: // wdio.conf.js specs: [ './wdio/test/specs/browser/**/*.js' ], – // wdio.conf.modeA.js specs: [ './wdio/test/specs/browser/modeA/*.js' ], exclude: [ './wdio/test/specs/browser/modeB/*.js' […]

蒙古语访问摩卡testing

所以我想在一些unit testing之后清理我的db(之前或之后)。 基本上,你将在我的代码块中看到的代码位于摩卡的afterAll块中。 我正在使用webdriver.io testrunner运行我的testing。 我不明白的是,如何从连接范围之外使用db的东西,请参阅: function createConnection(){ MongoClient.connect('mongodb://127.0.0.1:24001/meteor', function(err, db) { if (err) throw err; console.log("connected to the mongoDB !"); let myCollection = db.collection('test_collection'); // do stuff with myCollection }); } 如果可能的话,我宁愿像这样: function createConnection(){ MongoClient.connect('mongodb://127.0.0.1:24001/meteor', function(err, db){ if (err) throw err; } } function getCollection(name){ return db.collection(name) //don't have db at this scope, problem? […]

如何在独立模式下同步运行webdriverio?

http://webdriver.io/guide/getstarted/modes.html 我要绝对坚持使用Chromedriverdebuggingwebdriveriotesting。 由于webdriverio命令是asynchronous的,并且浏览器会话与testing不同步,因此您无法单步执行代码。 这是令人沮丧的,因为阅读文档,看起来你需要像Chai或wdio这样的testing框架来生成testing,但是这似乎有很多工作只是为了有程序上的同步命令。 我只需要使用webdriverio抓取一些网站,但这个asynchronous命令太难以使用Chrome开发工具进行debugging。 有没有办法强制webdriverio行为同步? EX) var loadedPage = webdriverio.remote(options).init().url('https://google.com'); 除了loadedPage没有准备好,并且在debugging移到下一行时未定义。