我想使用类似于 Selenium 等框架中存在的页面对象模式的工作流程。login.spec.js我想在 my 中使用 my editSettings.spec.js,因为它需要用户登录。
我如何在赛普拉斯中实现这一目标?我可以从一个测试文件导出函数以在另一个测试文件中使用吗?
有一个网站只有在我运行 OpenVPN Connect 2.1.3.111 配置文件时才能访问。我需要使用 Testcafe 访问该网站,但到目前为止我还没有找到任何关于将 Testcafe 与 VPN 结合使用的文档。有什么我可能错过的吗?
测试目标是确认如果用户上传新图片,上传图片的 'src' 属性会发生变化,这意味着图片已更改。
我尝试使用几种方法,概述如下。
第一种方法
cy.get('.img').then($img => {
//store the src
const source = $('img').attr('src');
/**
* File drop 2mb jpg
*/
cy.fixture(Cypress.env("JPG_2MB_ASSET"), "base64").then(fileContent => {
cy.get(".dropzone").upload(
{
fileContent,
fileName: "sampleimage.jpg",
mimeType: "image/jpeg"
},
{ subjectType: "drag-n-drop" }
);
});
cy.wait(16000);
cy.get('img')
.attr('src')
.should($src2 => {
expect($src2).not.to.eq(source);
});
Run Code Online (Sandbox Code Playgroud)
第二种方法
//store the src
const source = $img.attr('src')
/**
* File drop 2mb jpg
*/
cy.fixture(Cypress.env("JPG_2MB"), "base64").then(fileContent => {
cy.get(".dropzone").upload(
{
fileContent,
fileName: "sampleimage.jpg",
mimeType: "image/jpeg"
},
{ subjectType: "drag-n-drop" }
); …Run Code Online (Sandbox Code Playgroud) 我为 TestCafé 使用了“testcafe-browser.provider-browserstack”插件。我尝试在我的应用程序中使用它,但我总是收到一条消息,提示登录错误。数据是正确的(只是“测试”这篇文章)
const createTestCafe = require('testcafe');
const BrowserStack = require("testcafe-browser-provider-browserstack");
let testcafe = null;
process.env.BROWSERSTACK_USERNAME="test";
process.env.BROWSERSTACK_PASSWORD="test";
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc;
const runner = testcafe.createRunner();
return runner
.src(['tests/fixture1.js', 'tests/ingo1.js'])
.browsers('browserstack:Chrome')
//.browsers(['chrome'])
.screenshots('allure/screenshots/', true)
.reporter('allure')
.run();
})
.then(failedCount => {
console.log('Tests failed: ' + failedCount);
testcafe.close();
});
Run Code Online (Sandbox Code Playgroud) automated-tests web-testing browserstack e2e-testing testcafe
我正在尝试在 Azure 发布管道期间运行 Cypress。我安装了我在本地安装的所有软件包,但是当我运行 Cypress 测试时,出现了几个错误:
TypeError: cy.visit(...).getByText 不是函数
类型错误:cy.getByLabelText 不是函数
类型错误:cy.getByPlaceholderText 不是函数
我已将以下包添加到我的package.jsondevDependencies 部分:
"@testing-library/cypress": "^4.0.4",
"@testing-library/react": "^8.0.4",
"@testing-library/dom": "latest",
Run Code Online (Sandbox Code Playgroud)
知道为什么赛普拉斯会返回这些 TypeErrors 吗?
这是一个笔试的例子:
it("can request to join private team", () => {
const privateTeamId = "fe1fa897-2e90-4ecb-91f9-0c9bb33ef63a";
cy.get(`[id=${privateTeamId}]`)
.click()
.getByText("Request membership")
.click()
.getByText("Membership request sent");
});
Run Code Online (Sandbox Code Playgroud) 我遇到了一个问题,在 Jest 中没有内置的方法来重试脆弱的测试。我正在使用 Jest + TS + Puppeteer。任何人都有同样的问题或可能的解决方案\建议?我试图实现这个 : link ,但没有成功。
jest-retries 对我不起作用,因为我创建了用户并做了很多操作,如果测试失败 - 重试在具有相同 cookie 等的同一个 Chrome 选项卡中重新启动测试。提前致谢!
代码示例:
const it = require('jest-retries');
describe('any tests', () => {
beforeEach(async () => {
await page.emulate(devices['Galaxy S5']);
await page.goto(newSearchUrl, { waitUntil: 'networkidle2' });
});
it('dummy test', 2, async () => {
await userSignup(); // custom wrapper for signup
await checkGraphqlSuccess('success dumb event');
const iconHeader = await waitForElementVisible(favoriteBtnHeader);
await iconHeader.click();
const number = await waitForElementVisible(number1);
const getNumber1 = await page.evaluate(obj => { …Run Code Online (Sandbox Code Playgroud) 我有一个带有 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) 我的意思是当我们像这样初始化 Selector 时:
let stringLocator = 'some element locator'
selector = new Selector(stringLocator)
Run Code Online (Sandbox Code Playgroud)
是否可以像这样获得原始字符串定位器:
selector.locator
Run Code Online (Sandbox Code Playgroud)
PS这个问题是与此相关的一个,我已经找到了一些解决方法哈克获得testcafe错误显示我的XPath定位。
我们的端到端测试基于 maven/CucumberJVM。所有工件均使用 Jenkins 构建并保存在 Artifactory 中。那么 tekton 应该适用于一个(或多个)环境
我将如何显示测试运行的结果?在 Tekton 仪表板中?已经有插件了吗?作为测试运行的结果,是否可以显示静态 html 文件?
提前感谢您的任何提示。最好的问候,英戈
这是我遇到的问题:
我在 Nest.js 中使用我的自定义记录器:
export class ReportLogger extends ConsoleLogger {
verbose(message: string) {
console.log('?Verbose?Reporting', message);
super.verbose.apply(this, arguments);
}
log(message: string) {
console.log('?Log?Reporting', message);
super.log.apply(this, arguments);
}
}
Run Code Online (Sandbox Code Playgroud)
和log.interceptor.ts文件:
export class LogInterceptor implements NestInterceptor {
constructor(private reportLogger: ReportLogger) {
this.reportLogger.setContext('LogInterceptor');
}
intercept(context: ExecutionContext, next: CallHandler) {
const http = context.switchToHttp();
const request = http.getRequest();
const now = Date.now();
return next
.handle()
.pipe(
tap(() =>
this.reportLogger.log(
`${request.method} ${request.url} ${Date.now() - now}ms`,
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
这是main.ts文件:
async …Run Code Online (Sandbox Code Playgroud) e2e-testing ×10
testcafe ×4
testing ×4
cypress ×3
automation ×2
browserstack ×1
dashboard ×1
javascript ×1
jestjs ×1
nestjs ×1
node.js ×1
openvpn ×1
puppeteer ×1
tekton ×1
typescript ×1
web-testing ×1