- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
好吧,所以我在这里一定做得很愚蠢,因为我无法让基本命令工作!
因此,在我的 nightwatchjs 脚本中,我想从下拉菜单选项中获取值列表,如下所示;
这是我的 JavaScript 代码;
'module.exports = {
Search using Make, Model and Price filters': function (browser) {
var c = browser.getElementById('ddl-make').children;
console.log(c);
}
};
但似乎不起作用。
我每次都会收到以下错误;
✖ TypeError:browser.getElementById 不是函数
(如果我将浏览器替换为文档,并且如果将getElementById替换为getElementByValue,我会得到相同的错误em>)
我是否对 getElementById 命令执行了明显错误的操作,从而导致了此错误?
谢谢
最佳答案
getElementById() 不是 NightwatchJS 提供的函数。然而它确实有一个带有 css 选择器的 element() 函数。
This is how their documentation describes the element() function:
Search for an element on the page, starting from the document root. The located element will be returned as a web element JSON object. First argument to be passed is the locator strategy, which is detailed on the WebDriver docs.
关于javascript - Nightwatchjs - getElementById 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58233421/
当我们从 Windows 迁移到 Linux 时,我们的 Nightwatch 测试不再运行。它只是卡住。 Selenium 服务器已在监听,并且 chrome_driver(linux 64 位)设
我正在使用 nightwatchJS 实现浏览器自动化。我看到的一个常见用例是,我网页中的大部分内容都是通过来自 ajax 调用的数据更新的。因此,在我的测试中,我正在寻找一种方法来保持我的测试,直到
我正在使用 nightwatch 并尝试遍历元素列表。但是,当我没有得到对象或元素时,我得到了一个字符串数组。 代码 browser.elements("css selector", ele, fun
我如何在夜间值类中单击元素命令返回的按钮 client.elements('xpath', ".//a[@class='abcd')]", function (allButtons){
我刚刚了解了 nighwatchjs 并尝试了解框架来编写我的测试。 在示例中,我可以注意到使用变量浏览器的 api - 我找不到关于 API 引用或任何外部文档的更多信息。 我想我理解页面对象设计模
我有一个问题,如果我使用测试脚本的绝对路径,我似乎只能运行单独的 nightwatchjs 测试。 例如,如果我从以下文件夹运行测试; /Users/darrenharley/Documents/Gi
我正在尝试使用 Nightwatch 打开我的网址,但之后无法关闭浏览器。 我尝试使用 timeouts ,以及 browser.end() 或 browser.closeWindow()。它们似乎都
我正在测试一个包含视频播放器的应用。我希望 Nightwatch 能够识别视频在点击播放按钮后正在播放,并在点击暂停按钮时暂停。我不是在谈论检测播放器发送的播放或暂停事件,而是检测视频是否正在实际播放
我希望在运行 nightwatchjs 测试时使用execute 填充应用程序中的字段 我尝试过以下方法: .execute("document.getElementByClassName('.pri
好吧,所以我在这里一定做得很愚蠢,因为我无法让基本命令工作! 因此,在我的 nightwatchjs 脚本中,我想从下拉菜单选项中获取值列表,如下所示; 这是我的 JavaScript 代码; 'mo
使用最新版本的网络驱动程序和 nightwatchjs。 使用下面的代码,我从来没有在gotTags中得到任何东西。如果我在以下范围内设置断点: browser.elementIdText(eleme
我想用 NightwatchJS 断言给定类名的所有元素是否可见。所以按照这些思路: module.exports = { //some tests 'page changes to
我在让我的守夜人测试从网页获取数据并将其打印到我的控制台时遇到了一些问题。如果有人能指出我正确的方向,我将非常感激。 每次我尝试将数据获取到我的控制台日志时,它只返回 [object Object]。
我正在尝试使用 nightwatch.js 自动执行一些 UI 测试,我需要从下拉列表中选择一个随机值,如下面的代码所示。 1 2 3 4 7 8 9 11 12 截至目前,我使用的方法不可靠,
我想截取整个页面的屏幕截图。我想要捕获的尺寸是宽度 - 1200px,高度 - 5000px。当我设置 resizeWindow(1200, 5000) 时,它不会将窗口扩展到超出我的桌面屏幕高度(1
我正在针对汽车品牌和型号的下拉菜单选项运行 nightwatchjs 测试脚本。 在选择汽车品牌之前,模型元素已正确禁用,如下所示; 当我选择一个品牌时,模型元素将变为启用状态,并且禁用的部分将被删除
可以使用 .frame JSON Wire Protocol 调用更深入地进入 DOM 树,但我还没有找到通过 DOM 树向上移动的方法。 module.exports = {
使用名为 NightWatch 的 JavaScript Selenium 工具,在应用测试之前确定 GUI 部分的良好做法是什么?例如,查找 A 或 B 上的情况,然后进行单独的测试。另一个例子,确
我一直在使用 nightwatch.js 并且总是点击元素。有没有办法可以将鼠标悬停在链接或按钮上? 最佳答案 试试 browser.moveToElement 命令。 您也可以在 moveToEle
我正在使用 nightwatchjs 来自动提交支持表单。使用 nightwatchjs 单击链接会在新窗口中打开表单页面。如何将焦点设置在该窗口上?任何帮助是极大的赞赏。 最佳答案 使用 switc
我是一名优秀的程序员,十分优秀!