자동화 매트 옵션에 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";});

매트 옵션이 태그 내에 있지 않는 매트-을 선택합니다. 그것은 외부의 매트-이 선택하고 내 div. 다른 방법이 있을 달성하는 자동화 매트 옵션?

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ý
..................................................................................................................