小编Ale*_*kin的帖子

Test Cafe - Getting error on clicking link which is invisible using Client Function

I have to click on a button that is invisible in Html. I tried using Client Function but I am getting an error for the element

import { Selector,ClientFunction } from 'testcafe';
fixture('Clicking Invisible link').page('http://example.com');

test('Click on invisible link', async t => {
  const viewProgram = Selector('tbody [viewBox]').nth(0);
  const clickViewProgram = ClientFunction(() => viewProgram().click());
  await clickViewProgram(); 
});
Run Code Online (Sandbox Code Playgroud)

The Error that I am getting is :

An error occurred in ClientFunction code: ReferenceError: viewProgram is not defined

Please help me …

javascript testing automated-tests e2e-testing testcafe

2
推荐指数
1
解决办法
155
查看次数

每晚在Test Cafe Studio中运行测试

我在Test Cafe Studios中创建了一个测试。我想让该测试每晚自动运行,而无需用户运行测试(打开程序,单击“开始”等),此软件是否可以实现?如果有一些解决此问题的示例,将很有帮助!我已经为一些非常基本的测试粘贴了一些代码,只是检查页面是否会打开。我已经用问题的一般信息填写了一些''

提前致谢。

Windows Task Scheduler

import { Selector } from 'testcafe';

fixture `svdemo`
.page `my website here `
.httpAuth({
    username: 'username',
    password: 'password',
    domain: 'domain'
});

test('Visit Each Page', async t => {
await t
    .click(Selector('span').withText('Page1'))
    .click(Selector('a').withText('Homepage'))
    .click(Selector('a').withText('Page2'))
    .click(Selector('a').withText('Homepage'))
    .click(Selector('a').withText('Page3'));
Run Code Online (Sandbox Code Playgroud)

});

我希望看到测试运行并每晚通过自己的测试。

javascript testing continuous-integration end-to-end testcafe

2
推荐指数
1
解决办法
88
查看次数

Selector 的调试值

也许是一个简单的问题,但我自己完全无法解决。

如何调试/输出选择器的值?

await t
            .expect(Selector('.progress-bar.progress-bar-success').getStyleProperty('width')).eql('100%', {timeout: 90000})
Run Code Online (Sandbox Code Playgroud)

我试着用

console.log(Selector('.progress-bar.progress-bar-success').getStyleProperty('width'));
Run Code Online (Sandbox Code Playgroud)

最后还有 .value 。但我没有得到任何信息。有任何提示吗?

testing debugging css-selectors selector testcafe

2
推荐指数
1
解决办法
74
查看次数

TestCafe - 如何通过 auth0 登录使用角色

我有一个带有 auth0 登录名的应用程序。我一直无法弄清楚如何t.useRole在这种情况下制作。

幸运的是,这很容易重现。auth0(应用程序)使用相同的进程。它以与我的应用程序完全相同的方式失败。

预期结果
- 用户登录
- 用户进入仪表板
- 用户保持登录状态
- 用户再次进入仪表板(第二次测试)

实际
- 用户登录
- 用户进入仪表板
- 用户不再通过身份验证
- 用户进入登录页面

import { Role, Selector, ClientFunction } from 'testcafe';

const getPageUrl = ClientFunction(() => window.location.href.toString());

const exampleRole: Role = Role('https://auth0.com/auth/login', async t => {
    const userNameInput = Selector('input').withAttribute('name', 'email');
    const passwordInput = Selector('input').withAttribute('name', 'password');
    const loginButton = Selector('button').withAttribute('name', 'submit');

    await t
        .wait(5000)
        .click(userNameInput)
        .typeText(userNameInput, userName)
        .click(passwordInput)
        .typeText(passwordInput, password)
        .click(loginButton);
})

fixture(`SAMPLE`)
    .page('https://manage.auth0.com/dashboard')
    .beforeEach(async t => {
        await …
Run Code Online (Sandbox Code Playgroud)

testing automation automated-tests e2e-testing testcafe

2
推荐指数
1
解决办法
285
查看次数

如何在基于 Chromium 的功能测试中使用导航器媒体设备?(测试咖啡厅)

TL;DR如何运行使用navigator.mediaDevicesTestCafe 和 Chromium 及其方法的功能测试?

我正在尝试使用 TestCafe 编写功能测试来测试一些 WebRTC 代码。我正在使用反应。我有一个枚举设备的自定义钩子:

function useUpdateDeviceList() {
  const dispatch = useDispatch();

  useEffect(() => {
    async function updateDeviceList() {
      const { audioInputs, videoInputs } = await getInputDeviceInfos();

      dispatch(setAudioInputs(audioInputs));
      dispatch(setVideoInputs(videoInputs));
    }

    updateDeviceList();

    console.log('navigator', navigator);

    navigator.mediaDevices.ondevicechange = updateDeviceList;

    return () => {
      navigator.mediaDevices.ondevicechange = null;
    };
  }, [dispatch]);
}
Run Code Online (Sandbox Code Playgroud)

哪里getInputDeviceInfos调用navigator.mediaDevices.enumerateDevices

当我在浏览器中运行此代码时,它可以完美运行。当它在 TestCafe 的功能测试中运行时,它抛出。

TypeError: Cannot set property 'ondevicechange' of undefined
Run Code Online (Sandbox Code Playgroud)

彻底的谷歌搜索只给出了添加标志--use-fake-ui-for-media-stream--use-fake-device-for-media-stream启动命令的答案(前者避免了授予摄像头/麦克风权限的需要,并且梯形图getUserMedia()根据文档提供测试模式而不是实时摄像头输入),其中我做了:

TypeError: Cannot …
Run Code Online (Sandbox Code Playgroud)

functional-testing chromium webrtc testcafe mediadevices

2
推荐指数
1
解决办法
189
查看次数

如何禁用和启用 recyclerview 滚动

我想在横向模式下禁用 recyclerview 滚动并在纵向模式下启用它。

 recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener() {
        @Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            // Stop only scrolling.
            return rv.getScrollState() == RecyclerView.SCROLL_STATE_DRAGGING;
        }
    });
Run Code Online (Sandbox Code Playgroud)

我正在使用此方法禁用滚动,但找不到再次启用它的方法。

谢谢你的帮助!

android android-recyclerview

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

node js:我要获取(子)exec 的输出并设置要重新调整的变量?

我一直在寻找一个真正的例子,但我找不到任何例子。我对 node js 完全陌生。

我正在设置一个使用命令行工具获取密码的服务。

命令行“pw get key”返回与密钥关联的密码。命令行“pw set key password”设置与密钥关联的密码。

到目前为止,我拥有的部分代码是:

const util = require('util');
const exec = util.promisify(require('child_process').exec);

async function cmdPwGet(key) {
  const { stdout, stderr } = await exec(`pw get ${key}`);
  console.log('stdout:', stdout); 
  console.log('stderr:', stderr);
}

async function cmdPwPut(key, passwd) {
  const { stdout, stderr } = await exec(`pw set ${key} ${passwd}`);
  console.log('stdout:', stdout);
  console.log('stderr:', stderr);
}

class PwService {

    constructor (KEY){
    this.basekey = KEY;
    this.pwd = "";
    }

    setPw (key, passwd) {
      key = this.basekey + …
Run Code Online (Sandbox Code Playgroud)

testing command-line exec node.js testcafe

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

TestCafe 团队是否计划正式支持 Gherkin (BDD)?如果不是,目前将 TestCafe 与 Gherkins 集成的最佳方式是什么?

我的团队有点像 TestCafe,但对采用它有一些保留意见。主要是支持 Gherkin 集成。gherkin-testcafe npm 包和示例https://github.com/helen-dikareva/testcafe-cucumber-demo似乎还没有准备好迎接黄金时段。

这是目前支持 BDD 的更可靠方式吗?

testing bdd gherkin e2e-testing testcafe

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

如何等待加载时间较长的页面加载testcafe?

从这些文档:https: //devexpress.github.io/testcafe/documentation/test-api/actions/navigate.html

看起来我们只能等待15秒才能加载页面.

我们开发了一个NextJS应用程序,它的首次加载需要40秒,因为它在第一次加载时构建应用程序.

我似乎无法使TestCafe在初始页面加载时没有超时.

我试过了

fixture('Restaurant List')
  .page('http://localhost:3000/something')
  .beforeEach(async () => {
    await waitForReact(120000);
  });
Run Code Online (Sandbox Code Playgroud)

例如没有成功.

automated-tests e2e-testing testcafe next.js

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

如何使用 testcafe 定位/单击选择器(按钮)

我正在尝试使用 testcafe 测试应用程序的提交。但是,我似乎无法让 testcafe 单击“提交申请”。

到目前为止,我已经尝试了以下方法:

.click(Selector('button').withText('Submit Applicaition'))
.click('#submit-application').withText('Submit Application')
Run Code Online (Sandbox Code Playgroud)

还有一些选择。

我什至无法让 testcafe 找到按钮

import {Selector} from 'testcafe';

fixture `MES login`
 .page `http://mes.coeo.com.au/`;

test('FindButton', async t => {

    await t
    .wait(2000)
        .navigateTo('/le12625-senior-exploration-geologist')
    .wait(2000);

    const one = await Selector('#submit-application');

    const two = one.exists;

    await t
        .expect(two).ok()

    await t
    .wait(5000)
        .click(Selector(one));
}
Run Code Online (Sandbox Code Playgroud)

谁能帮我解释一下是我的 testcafe 脚本还是网站的构建方式,以及如何让 testcafe 单击按钮?

非常感谢。

网站链接

javascript automated-tests button e2e-testing testcafe

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