标签: webdriver-io

第二次测试不会改变URL

我有两个测试.第一次测试成功通过.然后在第二个测试中有一个url方法调用,但它不会更改浏览器中的url.

wdio.conf.js中的baseUrl设置为http://localhost/web/es/index.html#

测试:

var assert = require('assert');

describe('user login ', function(){

    it('user login', function(){

        browser
            .url('/system/login')
            .setValue('[name="username"]','test')
            .setValue('[name="password"]','test')
            .click('=Potvr?');            

        assert(browser.waitUntil('=test test'));                
    });

    it('user form', function(){

        browser
            .url('/user/form');
    });
});
Run Code Online (Sandbox Code Playgroud)

在第一次测试/ system/login中正确打开.但在第二次测试中,网址永远不会更改为/ user/form

我刚开始使用webdriverio所以我错过了什么?

javascript webdriver-io

7
推荐指数
1
解决办法
524
查看次数

使用spectron测试电子应用程序重新启动时丢失webdriverio会话

我正在使用spectron对我的电子应用程序运行集成测试.除了尝试测试应用程序设置在应用程序重新启动之间正确保留之外,一切正常.

在运行测试时,我的应用程序启动userData每个测试的新临时目录,以确保测试被隔离.这意味着持久性测试需要理想地在单个测试中进行,为实现这一点,我必须在测试过程中重新启动应用程序.有一种app.restart方法,所以必须得到支持吗?

我正在使用以下光谱测试代码:

// save some settings here

await app.restart();
await app.client.waitUntilWindowLoaded()

// do some more checking to ensure the app is fully loaded
// check the settings here
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

Error: waitUntilWindowLoaded Promise was rejected with the following reason: 
Error: A session id is required for this command but wasn't found in the response payload
Run Code Online (Sandbox Code Playgroud)

这样做的正确方法是什么?我也尝试停止Application实例并启动一个具有类似结果的新实例.

webdriver-io electron spectron

7
推荐指数
1
解决办法
813
查看次数

挂在Yarn上的Fibers/node-gyp安装在Windows上

貌似wdiofibers作为依赖,使用node-gyp,这显然不会没有的Python 2.7在Windows上运行.

现在我已经安装了,我没有得到"missing PYTHON"错误,但它永远挂在命令正在做的任何事情 - 光纤.

永远挂在纤维上

javascript node.js node-gyp webdriver-io yarnpkg

7
推荐指数
1
解决办法
386
查看次数

如何在 CodeceptJS 中尝试 Catch

我在我的页面对象中这样做:

try{
    I.selectOption(this.SELECT, this.OPTION);
}
catch(error){
    I.say('Option missing, but thats sometimes expected ' + error);
}
Run Code Online (Sandbox Code Playgroud)

但是当定位器与选项元素不匹配时,它仍然无法通过测试。

我想赶上并继续测试,而不会失败。

更新:

看起来这取决于 try 块中的内容。

如果我在那里放一个断言,比如I.see('something');然后不跳过 catch 块。但是 try 块中的非断言,例如I.selectOption('something')抛出未被 catch 捕获的错误。

javascript try-catch node.js webdriver-io codeceptjs

7
推荐指数
1
解决办法
2372
查看次数

Selenium 服务器错误:无法创建新服务 chromedriverservice

我正在尝试在我的 Windows 10 计算机上运行 webdriverio,并在尝试运行我的测试 js 文件时一直遇到同样的问题。所以我运行它-jar /your/download/directory/selenium-server-standalone-3.5.3.jar 来启动服务器,然后输出

13:06:19.471 INFO - Selenium build info: version: '3.5.3', revision: 'a88d25fe6b'
13:06:19.472 INFO - Launching a standalone Selenium Server
2018-02-16 13:06:19.503:INFO::main: Logging initialized @301ms to org.seleniumhq.jetty9.util.log.StdErrLog
13:06:19.564 INFO - Driver class not found: com.opera.core.systems.OperaDriver
13:06:19.600 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
 registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN10
13:06:19.640 INFO - Using the passthrough mode handler
2018-02-16 13:06:19.673:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2018-02-16 13:06:19.697:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@3e9b1010{/,null,STARTING} …
Run Code Online (Sandbox Code Playgroud)

javascript selenium node.js webdriver-io

7
推荐指数
4
解决办法
4万
查看次数

无法在 Visual Studio 代码中为“npx”启动的应用程序启动调试

我需要以这种方式启动一个特定的 .js 文件来执行:

  1. npx app.js launch.conf.js //用于执行脚本

  2. npx app.js debug.conf.js //用于调试脚本

在我的 debug.conf.js 中包含

const config = {
  debug: true,
  execArgv: ['--inspect-brk'],
  maxInstances: 1,
  cucumberOpts: {
    timeout: 30 * 1000 * 4,
  },
};
exports.config =config
Run Code Online (Sandbox Code Playgroud)

, 当我通过 CMD 执行第二个命令时,我可以使用 chromedev 工具调试器进行调试。但是当我需要使用 VS 代码编辑器进行调试时:这存在于我的 launch.json 文件中:

"type": "node",
"name": "manager",
"request": "launch",
"protocol": "auto",
//  "port": 5859,
"program": "${workspaceRoot}\\node_modules\\cdem\\bin\\app",
"execArgv": ["--inspect-brk"],
"args": [
    "run wdio.debug.conf.js"
]
Run Code Online (Sandbox Code Playgroud)

我一直将控制台操作设为:附加调试器,等待调试器断开连接并且未启动执行。

有人可以让我如何使用 VS Code 调试这个应用程序吗?

debugging node.js webdriver-io visual-studio-code

7
推荐指数
1
解决办法
2293
查看次数

下载 chromedriver v121.0.6167.184 失败:下载失败:服务器返回代码 404。URL:https://edgedl.me.gvt1.com/

下载 chromedriver v121.0.6167.184 失败:下载失败:服务器返回代码 404。 URL:https: //edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/121.0.6167.184/win64/chromedriver-win64 .zip,重试...

面临 WebdriverIO 问题

无法下载 chrome 以实现自动化

“devDependencies”:{“@alfonso-presa/soft-assert”:“^0.6.0”,“@wdio/cli”:“^8.21.0”,“@wdio/cucumber-framework”:“^8.21。 0", "@wdio/local-runner": "^8.21.0", "@wdio/sauce-service": "^8.23.0", "@wdio/spec-reporter": "^8.21.0" 、“axios”:“^1.6.4”、“chai”:“^4.3.10”、“cucumber-html-reporter”:“^7.1.1”、“dotenv”:“^16.3.1”、“ fs-extra”:“^11.1.1”,“multiple-cucumber-html-reporter”:“^3.5.0”,“n-readlines”:“^1.0.1”,“路径”:“^0.12。 7", "wdio-cucumber-reporter": "^0.0.2", "wdio-cucumberjs-json-reporter": "^5.1.8" },

chromium selenium-chromedriver webdriver-io

7
推荐指数
1
解决办法
4116
查看次数

在webdriver.io中查找父元素

我在原始webdriver中看到了几个使用getAttribute('xpath')并附加到'/ ..'的解决方案,但webdriver.io没有xpath属性,所以我无法使用它.关于如何抓取父元素的任何想法?

我试图测试的情况是在引导程序布局中,实际上我正在尝试检查的类的元素是上面的一个.它看起来像这样:

<div class="form-group">
  <input class="form-control" type="text" name="username">
  <other stuff>
</div>
Run Code Online (Sandbox Code Playgroud)

我通过driver.element选择("input [name ='username'"],但错误类实际上击中了div

<div class="form-group error">
  <input class="form-control" type="text" name="username">
  <other stuff>
</div>
Run Code Online (Sandbox Code Playgroud)

所以我需要检查div本身是否有错误类,而不是我能找到的输入(div上没有uniques)

任何帮助将不胜感激.

webdriver-io

6
推荐指数
1
解决办法
5151
查看次数

browser.keys()无法在Firefox 53.0和webdriver.io上运行

在firefox上,browser.keys抛出错误.

Os: MacOs
Firefox version: 53.0.3
Geckodriver: 0.16.1
Webdriver.io: 4.8

请帮我解决这个错误.

这是日志

[17:11:35]  COMMAND POST     "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/url"
[17:11:41]  COMMAND POST     "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/refresh"
[17:11:45]  COMMAND GET      "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/window/current/size"
[17:11:46]  COMMAND POST     "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/elements"
[17:11:46]  COMMAND GET      "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/element/0/displayed"
[17:11:46]  COMMAND GET      "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/element/1/displayed"
[17:11:46]  COMMAND POST     "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/elements"
[17:11:46]  COMMAND GET      "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/element/0/displayed"
[17:11:46]  COMMAND GET      "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/element/1/displayed"
[17:11:46]  COMMAND POST     "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/elements"
[17:11:47]  COMMAND POST     "/wd/hub/session/97804a03-d52a-4232-9e3c-41e1fac6a9c5/element/0/value"
WARNING: the "keys" command will be depcrecated soon. Please use a different command in order to avoid failures in your test after updating WebdriverIO. …

webdriver selenium-webdriver webdriver-io geckodriver

6
推荐指数
1
解决办法
3450
查看次数

如何使用WebdriverIO上传文件

我正在尝试将带有selenium-webdriver gem的Ruby中的以下代码移植到带有WebdriverIO的Node.js:

@webdriver.navigate.to "https://imgur.com/upload"
element = @webdriver.find_element(:id, 'global-files-button')
element.send_keys("C:\\test\\image.png")
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,代码非常简单:导航到URL,找到输入,设置文件路径,并按预期工作,选择要上载的文件.

这是我的移植版本:

describe('User can upload', () => {
  it('select file', () => {
    browser.url("https://imgur.com/upload");
    browser.waitForExist('#global-files-button');
    $('#global-files-button').keys("C : \\ t e s t \\ i m a g e . p n g".split(" "));
  });
});
Run Code Online (Sandbox Code Playgroud)

不幸的是,这个测试没有设置路径,我无法找到一个使用wdio上传这样的文件的工作示例,文档让我猜测.任何建议非常感谢.

我知道chooseFile和uploadFile,但我正在使用云平台来运行我的wdio测试,但它们似乎无法可靠地工作.

webdriver node.js selenium-webdriver webdriver-io

6
推荐指数
1
解决办法
3883
查看次数