自动化的垫子-选择在testcafe

0

的问题

试图自动化拉使用以下的方法,但拉价值观不能以选择。

方法1:

const comboOption = Selector("mat-option").child("span").withExactText("Hello");
await t.click(comboOption);

方法2:

ClientFunction(() => {
  document.getElementsByClassName('mat-option-text')[0].innerText = 'Hello';
  document.getElementsByClassName('mat-option-text')[0].click();
  return "Hello";});

垫子-选项的标签是不是在垫子-选择。 这是外面的垫子-选择和内部标记。 是否还有其他的方式来实现自动化的垫子-选择?

1

最好的答案

1

谢谢你的代码段。

据我了解,你正试图击一个选项元素在另一个选择元。 我创建了一个简单的试验,应该执行的步骤的说明:

import { Selector } from 'testcafe';

fixture`Getting Started`
    .page`http://devexpress.github.io/testcafe/example`;
const selectElement = Selector('#preferred-interface');
const optionElement = selectElement.find('option');

test('My first test', async t => {
    await t
    .click(selectElement)
    .click(optionElement.withText('Both'))
    .expect(selectElement.value).eql('Both');
});

如果我误会了您的问题,可以请你分享一个简单的例子。html和详细的描述 你想要做什么测试及其结果你期待什么呢?

2021-11-23 09:01:50

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................