我现在正在使用WebdriverIO和开发一个网络应用程序。这些天我尝试根据输入设置日期type="date",但出现错误
无效元素状态:元素必须是用户可编辑的才能清除它。
并发现我可以通过使用来消除错误addValue(),但该值仍然不会被任何 API 清除。
client.clearElement('#deadline')
Run Code Online (Sandbox Code Playgroud)
还得到
无效元素状态:元素必须是用户可编辑的才能清除它。
如何从表单中删除该值?
我有一个简单的 iOS 自动化脚本。但在产生以下错误之后,它会在指定的模拟器上启动 WebDriverAgent
[调试] [XCUITest] 无法启动 WebDriverAgent 会话:无法将命令代理到远程服务器。原始错误:错误:连接ECONNREFUSED 127.0.0.1:8100
注意:即使我随机生成端口并在功能中设置 wdaLocalPort,它始终使用8100端口。
供您参考,请查找以下代码,用于在模拟器上启动应用程序。
安装程序.java
int wdaDevicePort = 8000 + (int)(Math.random() * ((9000 - 8000) + 1));
File app = new File(inputMap.get(CommonConstant.APK_FILE_OR_WEBDRIVER_PATH));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
capabilities.setCapability(MobileCapabilityType.VERSION, inputMap.get(CommonConstant.BUILD_VERSION));
capabilities.setCapability(MobileCapabilityType.PLATFORM, inputMap.get(CommonConstant.PLATFORM_NAME));
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, inputMap.get(CommonConstant.DEVICE_NAME));
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.UDID, inputMap.get(CommonConstant.PHYSICAL_DEVICE_ID));
capabilities.setCapability("wdaLocalPort", wdaDevicePort);
capabilities.setCapability("useNewWDA", true);
capabilities.setCapability("app", app.getAbsolutePath());
driverUrl = inputMap.get(CommonConstant.DRIVER_URL);
driverUrl = driverUrl.replace("Port", Integer.toString(appiumPort));
driver = new IOSDriver(new URL(driverUrl), capabilities);
Run Code Online (Sandbox Code Playgroud)
在WebDriverAgentRunner xcode项目文件中的FBConfiguration.m中随机生成端口。
+ (NSRange)bindingPortRange
{
int …Run Code Online (Sandbox Code Playgroud) 我是 Appium 的新手,我想为我的 Android 应用程序创建一个测试,
使用设备监视器中的检查器,我找到了我的元素资源 ID:com.appPackage:id/categoryIconImageView。我像下面这样使用它。而且我不知道为什么它不能正常工作?
const wdio = require("webdriverio");
const opts = {
port: 4723,
desiredCapabilities: {
platformName: "Android",
deviceName: "emulator-5556 device",
udid: "emulator-5554",
platformVersion: "8.0.0",
appPackage: "com.appPackage",
appActivity: "com.appActivity",
appWaitActivity: "com.appWaitActivity",
noReset: "true",
}
};
const client = wdio.remote(opts);
var s= client.init().element("#com.appPackage:id/categoryIconImageView").click().end();
Run Code Online (Sandbox Code Playgroud)
阿皮姆日志
[HTTP] --> POST /wd/hub/session/028abf5e-43a7-44f6-ab27-9d49e56bab8e/element
[HTTP] {"using":"-android uiautomator","value":"new UiSelector().resourceId('com.opensooq.OpenSooq:id/categoryIconImageView')"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["-android uiautomator","new UiSelector().resourceId('com.opensooq.OpenSooq:id/categoryIconImageView')","028abf5e-43a7-44f6-ab27-9d49e56bab8e"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] …Run Code Online (Sandbox Code Playgroud) 打开外部应用程序?
https://webiste.com 想要打开此应用程序。
[x] 始终允许 website.com 在关联的应用程序中打开此类链接
[取消] [打开外部应用程序]
我正在尝试自动化使用外部应用程序的流程。Chrome 正在请求打开应用程序的权限(见上文),但我无法找到一种方法来自动与该对话框进行交互。
有人建议我可以通过将命令行参数传递给 Chrome 来禁用该对话框。我得到了这份清单,但它很大,而且我没有找到任何看起来有帮助的东西。
如果有人曾经成功地使用外部应用程序实现了自动化,请告诉我你是如何做到的。谢谢。
编辑:
这些是自动化框架用于启动 Chrome 的参数:
使用以下标志启动 Google Chrome: --enable-automation --disable-popup-blocking --disable-extensions --disable-background-networking --disable-background-timer-throtdling --disable-backgrounding-occlusion-windows --禁用同步 --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --no-default-browser-check --disable-hang-monitor --disable-prompt -on-repost --禁用客户端网络钓鱼检测 --password-store=basic --use-mock-keychain --disable-component-extensions-with-background-pages --disable-breakpad --disable -dev-shm-usage --disable-ipc-flooding-protection --disable-renderer-backgrounding --force-fieldtrials=*BackgroundTracing/default/ --enable-features=NetworkService,NetworkServiceInProcess --disable-features=site-每个进程,TranslateUI,BlinkGenPropertyTrees --window-position=0,0 --window-size=1200,900
我可以轻松添加标志。不确定是否删除标志。
我正在尝试使用简单的 webdrioverio e2e 测试设置一个示例 Angular 项目,但在我的 e2e 测试中遇到了一些编译错误。
\n该项目主要使用以下文件进行设置:
\ne2e / test / [e2e test code]\ne2e / tsconfig.e2e.json\ne2e / wdio.conf.js\npackage.json\ntsconfig.json\nRun Code Online (Sandbox Code Playgroud)\n我的基地tsconfig.json看起来像:
{\n "compileOnSave": false,\n "compilerOptions": {\n "baseUrl": "./",\n "outDir": "./dist/out-tsc",\n "sourceMap": true,\n "declaration": false,\n "downlevelIteration": true,\n "experimentalDecorators": true,\n "module": "esnext",\n "moduleResolution": "node",\n "importHelpers": true,\n "target": "es2018",\n "lib": [\n "es2018",\n "dom"\n ]\n },\n "angularCompilerOptions": {\n "fullTemplateTypeCheck": true,\n "strictInjectionParameters": true\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n看起来tsconfig.e2e.json像:
{\n "extends": "../tsconfig.json",\n "compilerOptions": {\n "module": "CommonJS",\n …Run Code Online (Sandbox Code Playgroud) 我正在使用 webdriverIO v7(最新稳定版本)和黄瓜。
我收到该错误:Error: The "from" argument must be of type string. Received undefined
这是堆栈跟踪:
2021-04-08T18:29:37.403Z ERROR @wdio/runner: TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
at validateString (internal/validators.js:120:11)
at Object.relative (path.js:437:5)
at getDefinitionLineAndUri (C:\my-project\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:184:27)
at buildStepDefinitionConfig (C:\my-project\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:124:7)
at SupportCodeLibraryBuilder.defineStep (C:\my-project\node_modules\cucumber\lib\support_code_library_builder\index.js:51:79)
at Object.<anonymous> (C:\my-project\src\step_definitions\/accountSummary_steps.js:6:1)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Module._compile (C:\my-project\node_modules\pirates\lib\index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Object.newLoader [as .js] (C:\my-project\node_modules\pirates\lib\index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Module._load (internal/modules/cjs/loader.js:878:14)
at Function.hookedLoader [as _load] (C:\my-project\node_modules\mockery\mockery.js:111:12)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18) …Run Code Online (Sandbox Code Playgroud) 根据WebdriverIO-Dokumentation,我可以将浏览器控制台日志记录的输出集成到 webdriverio-logging 中。我的电话是然后browser.getLogs('browser')。但是,仅检索使用 console.warn() 发出的日志消息。所有 console.log() 消息都将被忽略。我如何管理它并将所有控制台消息包含到我的 webbriverio 报告中?
由于 Protractor 已被弃用,我刚刚开始使用 WebdriverIO。
之前我们使用 Angular 的 Component Harness 进行测试。当我们尝试迁移现有测试时,我们发现 Angular 团队实现了“@angular/cdk/testing/selenium-webdriver”作为 Protractor-harness 环境的替代品。
当我将 WebdriverIO 浏览器的对象传递给 SeleniumWebDriverHarnessEnvironment 时,我现在遇到了拦截器。有人可以帮助我找到解决方案吗?
import { SeleniumWebDriverHarnessEnvironment } from "@angular/cdk/testing/selenium-webdriver";
const harnessLoader: HarnessLoader = SeleniumWebDriverHarnessEnvironment.loader(driver);
Run Code Online (Sandbox Code Playgroud)
我收到错误如下
'TypeError: root(...).findElements is not a function'.
at .\src\cdk\testing\selenium-webdriver\selenium-web-driver-harness-environment.ts:43:14
Run Code Online (Sandbox Code Playgroud) 先谢谢您的帮助。
这个问题似乎在其他地方被问过并得到回答,但我相信我已经尝试了所有这些解决方案,但未能取得真正的进展。
我正在尝试为 webdriverIO 创建一个自定义报告器。但是,当所有导入都运行时,我收到以下错误:
语法错误:无法在模块外部使用 import 语句
如果我尝试执行文件顶部的导入语句wdio.conf,则会出现上述错误import WebdriverTestrailsReporter。我可以通过使用 require 来解决这个问题,但是在import WDIOReporter from '@wdio/reporter'.
当我尝试添加"type": "module"到 package.json 时,出现新错误:
错误[ERR_REQUIRE_ESM]:必须使用导入加载ES模块:/Users/XXXXX/WebstormProjects/integration_test_framework/wdio.conf.local.js 不支持ES模块的require()。/Users/XXXXX/WebstormProjects/integration_test_framework/node_modules/@wdio/config/build/lib/ConfigParser.js 中的 /Users/XXXXX/WebstormProjects/integration_test_framework/wdio.conf.local.js 的 require() 是一个 ES 模块文件,如下所示它是一个 .js 文件,其最近的父 package.json 包含 "type": "module" ,它将该包范围内的所有 .js 文件定义为 ES 模块。相反,将 wdio.conf.local.js 重命名为以 .cjs 结尾,更改所需代码以使用 import(),或从 /Users/n1531435/WebstormProjects/integration_test_framework/package.json 中删除 "type": "module"。
使用 cjs 文件扩展名让我回到开始时出现的导入错误。我无法更改所需的代码,因为它存在于我的项目中WDIO ConfigParser,而不是我的项目中。
我还对 tsconfig 中的值进行了相当多的修改,包括目标值(es2015、es2017),但似乎没有任何效果。有任何想法吗?
据我了解,此设置中有 4 个相关文件。我将它们复制如下:
wdio相关文件片段:
wdio.conf.js
//const WebdriverTestrailsReporter = require('./src/test/ui/WebdriverTestrailsReporter.js'); …Run Code Online (Sandbox Code Playgroud) 用于webdriverio创建 SaaS 测试。我想添加鼠标动画,animejs以便我可以记录测试以生成操作视频。
在我的webdriverio测试中(addAdditionalUsers.spec.js),我有
await closeBtn.animateMouse(); //line 34
Run Code Online (Sandbox Code Playgroud)
我animateMouse从以下进口functions.js:
export async function animateMouse() {
await browser.addCommand('animateMouse', async function() {
await this.waitForExist();
const rect = await browser.execute(elem => elem.getBoundingClientRect(), await this);
const targetX = rect.x;
const targetY = rect.y;
anime({ //line 32
targets: '#webdriver-mouse',
left: targetX + 'px',
top: targetY + 'px',
duration: 1000, // Duration of the animation in milliseconds
easing: 'linear'
})
}, true);
}
Run Code Online (Sandbox Code Playgroud)
当我运行测试时,我收到一个错误:
ReferenceError: …Run Code Online (Sandbox Code Playgroud) webdriver-io ×10
selenium ×3
angular ×2
appium ×2
javascript ×2
typescript ×2
android ×1
angular-cdk ×1
animejs ×1
automation ×1
cucumber ×1
java ×1
logging ×1
node.js ×1
puppeteer ×1
tsconfig ×1
webdriver ×1