![](/img/trans.png)
[英]TestCafe Typescript - how to assert the value of a disabled html input element?
[英]testcafe - how to assert text contains in html body
我使用testcafe進行api測試,但我們的api需要登錄。 以下是我的代碼。 我可以看到json的反應很好。 但我不知道如何在頁面上斷言。
import { Selector } from 'testcafe'; import Page from './page'; // Page model const page = new Page(); const url = 'https://myexample.com'; const elementWithIdOrClassName = Selector(value => { return document.getElementById(value) || document.getElementsByTagName(value); }); fixture `Test` .page(url + '/talent/career') .beforeEach( async t => { await t .typeText(page.username, 'gvp50') .typeText(page.password, 'password') .click(page.login_button) }); // Tests test('Text typing basics', async t => { await t .navigateTo(url+'/api/learner/learning_items') .expect(Selector('html')).contains('learning_items'); });
我運行此代碼后,Testcafe就會掛起。 我也嘗試了Selector('body'),但它不起作用。
const cellcomparedata =await Selector('[role="gridcell"]').textContent;
console.log("cellcomparedata is",cellcomparedata);
或者你可以使用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.