小编Ale*_*kin的帖子

Is there any way to click the "Sign In" link on github page using javascript for testcafe?

I want to click the "Sign In" on the GitHub page for testcafe using javascript. From inspecting part I found that "Sign in" part has a class name. So I was trying to use "Selector" to select that particular class. But it is giving me this error. "The specified selector does not match any element in the DOM tree.

   Selector('HeaderMenu-link no-underline mr-3').withText('Sign in')
Run Code Online (Sandbox Code Playgroud)

javascript automated-tests github e2e-testing testcafe

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

如何在 testcafe 中存根 window.open

我想在 testcafe 中模拟 window.open 函数。这样如果我的应用程序调用 window.open 而不是点击实际的,我们可以使用模拟

这样的事情会更好

onBeforeLoad: (window) => {
   cy.stub(window, 'open');
}
Run Code Online (Sandbox Code Playgroud)

testing automated-tests mocking e2e-testing testcafe

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

将多个文件中的固定装置和测试导入到 main.js 文件中时,TestCafe “固定装置未定义”错误

我无法将测试和固定装置导入到一个 main.ts 文件中以立即运行所有测试。出于组织目的,我将测试组织到单独的文件夹中。我收到错误:

ERROR Cannot prepare tests due to an error.
ReferenceError: fixture is not defined
Run Code Online (Sandbox Code Playgroud)

我创建了一个 main.ts 文件来运行所有测试。我导入 Fixture()、Test1() 和 Test2()。

主要.ts

import { Fixture } from "../utils/envUtils";
import { Test1 } from "./testSet1/test1";
import { Test2 } from "./testSet2/test2";

Fixture();
Test1();
Test2();
Run Code Online (Sandbox Code Playgroud)

夹具.ts

export const Fixture = () => {
    fixture("Running tests")
}
Run Code Online (Sandbox Code Playgroud)

测试1.ts

export function Test1() {
    test("Test1", async (t: TestController) => {
         ...
    }
}
Run Code Online (Sandbox Code Playgroud)

测试2.ts

export function Test2() {
    test("Test2", async (t: TestController) => { …
Run Code Online (Sandbox Code Playgroud)

testing automation typescript e2e-testing testcafe

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

编写 login() 函数的最终黄金标准是什么?

我在网上搜索最终的“登录模式”,其中包括登录实际成功的验证。问题 -根据我们在团队中决定的 DRY 和编码约定,我们不允许在 Pagemodels 中使用expect(又名断言)。这是当前的登录方法,有时仍然不稳定。我想问你亲爱的 Automators,你是如何设计包括验证在内的登录的?

/**
 * Actual login function
 */
async performLogin(): Promise<void> {
   console.log(`perform login`);
   await t
   .typeText(this.Email, username, {
      replace: true,
      paste: true
   })
   .typeText(this.Password, password, {
      replace: true,
      paste: true
   })
   .click(this.buttonSignIn)
}

/**
 * Login validation
 */
async login(): Promise<void> {
   await t.wait(7000)
   const getURL: any = ClientFunction(() => window.location.href)
   let currentURL: string = await getURL()

   while (currentURL === basePM.urlLogin) {
      this.performLogin()
      await t.eval(() => location.reload(true))
      currentURL = await getURL()
   } …
Run Code Online (Sandbox Code Playgroud)

javascript authentication testing automation testcafe

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

使用 lodash 从数组中查找子字符串并将它们推送到另一个,然后将结果与第三个表进行比较

我有数组:

all [a,b,ac,d, A]
Run Code Online (Sandbox Code Playgroud)

我想在这个中找到包含子字符串“a”(“A”)的所有元素,使用来自 lodash 的过滤器并将它们推送到另一个 - 到 filterTab

   const item = "a"
Run Code Online (Sandbox Code Playgroud)

我尝试这样:

import { some, method, differenceWith, isEquel } from 'lodash';
const filterTab = [];

filterTab.push (some(all, method('match',/item/i)));
Run Code Online (Sandbox Code Playgroud)

但它不起作用。

下一步如果它有效 - 它将是这样的:

var dif = differenceWith(filterTab, array3, _.isEqual);
Run Code Online (Sandbox Code Playgroud)

我不知道为什么它不起作用......

javascript testing lodash e2e-testing testcafe

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

在 Docker 容器中的 Chrome Headless 上运行 Testcafe 脚本

我有一个 Testcafe 脚本 ( script.js)。我想在 Chrome 浏览器上运行它,但以无头模式运行。所以,我使用以下命令。

testcafe chrome:headless script.js
Run Code Online (Sandbox Code Playgroud)

这很好用。但是,现在我希望对其进行 Docker 化并在容器中运行它。目的是让它在 Kubernetes 中运行。我怎样才能实现这个目标?

我看到Testcafe Docker 镜像,但这只是为了运行 Testcafe 实例。它不能满足我在容器中的 Chrome Headless 中运行此脚本的要求。

这个问题和我问的不一样)

testing google-chrome docker kubernetes testcafe

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

我们可以用 Promise 替换 Async/Await

我们可以在下面的代码中使用 Promise 而不是 async/await 吗?


fixture`MyFixture`.page`http://devexpress.github.io/testcafe/example`;

test("My first test", async t => {
  await t
    .typeText("#developer-name", "srikanth chitla")
    .setTestSpeed(0.1)
    .click("#submit-button");
});
Run Code Online (Sandbox Code Playgroud)

javascript testing promise async-await testcafe

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