我正在使用 Spectron 测试一个 Electron/React 应用程序,它使用WebdriverIO 命令 API。我想测试一些组件的属性,但我想确保我只在组件重新加载后测试它们。
正常的 WebDriverIO 等待命令,如waitForText()或waitForExist(),等待一些更改,但我需要等到组件重绘发生。例如,组件在重绘之前已经存在或已经有一些文本。这意味着对文本的任何测试都将在重绘之前进行,我不会测试新文本。有没有等待重绘的通用方法?
我想从 WebStorm 装订线(左侧的绿色三角形图标,按行号)运行 WebdriverIO + Mocha 测试。
\n\n\n\n但是当我按运行三角形时 - 发生错误:
\n\n/Users/ilyubin/.nvm/versions/node/v10.15.0/bin/node /Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/bin/_mocha --ui bdd --reporter /Applications/WebStorm.app/Contents/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js /Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/test/specs/catalog/not.found.page.spec.js --grep "^\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd1\x8b \xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x86\xd1\x8b \xd0\xbe\xd1\x88\xd0\xb8\xd0\xb1\xd0\xbe\xd0\xba \xd0\x9f\xd0\xbe\xd0\xb8\xd1\x81\xd0\xba \xd0\xbd\xd0\xb5\xd1\x81\xd1\x83\xd1\x89\xd0\xb5\xd1\x81\xd1\x82\xd0\xb2\xd1\x83\xd1\x8e\xd1\x89\xd0\xb5\xd0\xb3\xd0\xbe \xd0\xb7\xd0\xb0\xd0\xbf\xd1\x80\xd0\xbe\xd1\x81\xd0\xb0$"\n/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/test/specs/catalog/not.found.page.spec.js:1\n(function (exports, require, module, __filename, __dirname) { import {expect} from \'chai\';\n ^\n\nSyntaxError: Unexpected token {\n at new Script (vm.js:79:7)\n at createScript (vm.js:251:10)\n at Object.runInThisContext (vm.js:303:10)\n at Module._compile (internal/modules/cjs/loader.js:657:28)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)\n at Module.load (internal/modules/cjs/loader.js:599:32)\n at tryModuleLoad (internal/modules/cjs/loader.js:538:12)\n at Function.Module._load (internal/modules/cjs/loader.js:530:3)\n at Module.require (internal/modules/cjs/loader.js:637:17)\n at require (internal/modules/cjs/helpers.js:22:18)\n at /Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/lib/mocha.js:324:27\n at Array.forEach (<anonymous>)\n at Mocha.loadFiles (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/lib/mocha.js:321:14)\n …Run Code Online (Sandbox Code Playgroud) 有没有办法让 webdriverio 等待页面加载?我看到在java中我可以有类似的东西:
executeScript("return document.readyState").equals("complete"));
或者
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
Run Code Online (Sandbox Code Playgroud)
有什么办法可以在 webdriverio 中做到这一点吗?我知道我可以使用 waits 来等待特定元素,但我正在寻找一种方法来等待整个页面加载
我将 WDIO 与 Jasmine 和 Chai 一起使用。
我收到以下错误,我已经尝试找到根本原因一天多了。
错误:超时 - 异步函数未在 10000 毫秒内完成(由 jasmine.DEFAULT_TIMEOUT_INTERVAL 设置)
代码:
describe('Lead Routing Functionality', () => {
beforeEach(function () {
LightningLeadPage.open();
LightningLeadPage.login();
console.log('[TEST STEP INFO]: Checking Header: ');
});
it('Verify validation', () => {
LightningLeadPage.click_app_launcher();
});
Run Code Online (Sandbox Code Playgroud)
*************
Run Code Online (Sandbox Code Playgroud)
export default class Lightning_Page {
click_app_launcher() {
console.log("[TEST STEP INFO]: Verify App launcher icon is present. ");
console.log('DEBUG : I am waiting...')
this.appLauncher().waitForExist(this.waitDuration());
console.log("[TEST STEP INFO]: Clicking on App Launcher");
this.appLauncher().click();
}
Run Code Online (Sandbox Code Playgroud)
我注意到 console.log('DEBUG : I am waiting...') …
显示错误消息:`错误 webdriver:由于未知命令,请求失败,状态为 404:找不到请求的资源,或者使用映射资源不支持的 HTTP 方法接收请求
错误 webdriver: 未知命令: 找不到请求的资源,或者使用映射资源不支持的 HTTP 方法接收请求
` wdio.conf.js 文件:
**let { join } = require('路径'); Exports.config = { port: 4723, // 默认 appium 端口 services: [ ['appium', { command : 'appium' }] ],
specs: [
'./test/specs/**/*.js'
],
maxInstances: 10,
capabilities: [{
platformName:'Android',
platformVersion:'9',
deviceName:'Pixel',
app:'D:/test/appium/test2/ApiDemos-debug.apk',
bail: 0,
baseUrl: 'http://localhost',
waitforTimeout: 60000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
framework: 'mocha',
Run Code Online (Sandbox Code Playgroud)
}**
package.json 文件: ** {
“名称”:“测试2”,
“版本”:“1.0.0”,
“描述”: ””,
“主要”:“index.js”,
“脚本”:{
"test": "./node_modules/.bin/wdio wdio.conf.js"
Run Code Online (Sandbox Code Playgroud)
},
“关键字”:[],
“作者”: ””, …
我正在使用 WebdriverIO 编写测试用例,我注意到为输入设置值的唯一方法是使用setValue. 这实际上设置了输入框的全部值。然而,我需要的是将字符一一输入到输入中。我需要这样做,因为我正在测试的元素会在您键入时显示 drodpown 选项。当我使用setvalue这些选项时,不会出现,因为它只是将值复制到输入。
我正在使用WebdriverIO和Mocha/Chai 为我的网站编写一些测试,但是当我这样做时:
it('select application', function(done) {
client
.click('.disciplinetext > table:nth-child(7) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(3) > button:nth-child(1)')
// more stuff
Run Code Online (Sandbox Code Playgroud)
该元素尚不存在(未呈现)..click()在实际尝试单击元素之前,是否应该隐式等待页面完成加载?
如果我在它之前拍这条线,它工作正常:
.waitFor('.disciplinetext > table:nth-child(7) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(3) > button:nth-child(1)',1000)
Run Code Online (Sandbox Code Playgroud)
但我不希望有抛出waitFor每前.setValue(),.click(),.getText(),或任何其他API命令.我错过了什么吗?
是否有等待整个页面加载的命令,或者在访问元素之前隐式等待的设置?
我正在寻找一个告诉我的人,当我使用chromedriver和selenium通过webdriverIO运行Testdrive时,如何避免每次输入用户名和密码都重新输入。我想要的是优化我的测试驱动器。一些线索???
这两个文件是一个模块的一部分,系统中有4个模块
第一个文件:
var name = 'Andrea' + Math.floor((Math.random() * 1000000) + 1);
var ssn = 'V-' + Math.floor((Math.random() * 1000000) + 1);
var url = 'http://someurl.com';
var new_contact = 'https://someurl.com/client/add';
describe('Some contact is create', function(){
it('Should login to the system', function(){
browser.url(url)
browser.setValue('#email','xxxxxxxx@xxxx.com')
browser.setValue('#password','xxxxxx')
browser.click('#submit');
});
it('Should be fill the form', function(){
browser.url(new_contact)
browser.waitForVisible('#addClient')
browser.setValue('#clientNameTextField-inputEl',name)
browser.setValue('#clientIdentidicationTextField-inputEl',ssn)
browser.setValue('#clientAddressTextField-inputEl','El busque')
browser.setValue('#clientCicyyTextField-inputEl','Valencia')
browser.setValue('#clientEmailField-inputEl','salvador.salvatierra@alegra.com')
browser.setValue('#clientPhoneTextField-inputEl','04141234567')
browser.setValue('[name="phone2"]','04147654321')
});
it('the contact is store',function(){
browser.click('=save)
browser.waitForExist('#viewClientInfoBalances')
browser.end;
});
});
Run Code Online (Sandbox Code Playgroud)
第二档:
var url = 'http://someurl.com';
describe('We get …Run Code Online (Sandbox Code Playgroud) javascript selenium-chromedriver selenium-webdriver webdriver-io
我正在使用webdriverio进行测试自动化.在wdio.conf.js文件中,我配置了'baseUrl'属性.我想从我的test .js文件中准备'baseUrl'属性值.请帮我看'baseUrl'的价值!
我是webdriverIO的初学者。我已经在Web驱动程序IO文档的帮助下开始使用TestRunner。我安装了节点并期望对此命令做出响应
./node_modules/.bin/wdio --help
Run Code Online (Sandbox Code Playgroud)
我使用定义了配置
./node_modules/.bin/wdio config
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时
./node_modules/.bin/wdio wdio.conf.js
Run Code Online (Sandbox Code Playgroud)
它给我以下错误
Error: Couldn't initialise launcher from service "chromedriver".
Error: Cannot find module 'chromedriver'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/userName/node_modules/wdio-chromedriver-service/build/launcher.js:9:21)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Launcher.getLauncher (/Users/userName/node_modules/webdriverio/build/lib/launcher.js:815:35)
at Launcher._callee$ (/Users/userName/node_modules/webdriverio/build/lib/launcher.js:234:49)
at tryCatch (/Users/userName/node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (/Users/userName/node_modules/regenerator-runtime/runtime.js:296:22)
at Generator.prototype.(anonymous function) [as next] (/Users/userName/node_modules/regenerator-runtime/runtime.js:114:21)
at step (/Users/userName/node_modules/webdriverio/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /Users/userName/node_modules/webdriverio/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
at new Promise …Run Code Online (Sandbox Code Playgroud) webdriver-io ×10
javascript ×4
selenium ×2
e2e-testing ×1
jasmine ×1
mocha.js ×1
spectron ×1
testing ×1
wdio-jasmine ×1
wdio-v4 ×1
wdio-v5 ×1
webstorm ×1