Javascript 从testcafe中打开的第N个模式中选择OK按钮
我在测试中打开了两个modals,我希望能够在第二个modals中单击OK按钮,然后在下面的html中选择第二个元素 我目前的代码是:Javascript 从testcafe中打开的第N个模式中选择OK按钮,javascript,html,automated-tests,e2e-testing,testcafe,Javascript,Html,Automated Tests,E2e Testing,Testcafe,我在测试中打开了两个modals,我希望能够在第二个modals中单击OK按钮,然后在下面的html中选择第二个元素 我目前的代码是: import { waitForReact } from 'testcafe-react-selectors'; import { Selector } from 'testcafe'; fixture `App tests` .page('http://localhost:3000/') .beforeEach(async () =>
import { waitForReact } from 'testcafe-react-selectors';
import { Selector } from 'testcafe';
fixture `App tests`
.page('http://localhost:3000/')
.beforeEach(async () => {
await waitForReact();
});
test('Can open and accept all pop ups', async t => {
//open first modal
await t
.click('#LayerAddingPopUpButtonID');
//select OK button from first modal
const modalOKButton = Selector('div.ant-modal')
.find('div.ant-modal-footer')
.find('button.ant-btn-primary');
//click OK button from first modal
await t
.expect(modalOKButton.with({visibilityCheck: true}).exists)
.ok({timeout: 30000})
.hover(modalOKButton)
.click(modalOKButton);
//open second modal
await t
.click('#LayerDeletingPopUpButtonID');
//select OK button from second modal
const secondModalOKButton = Selector(??);
});
我正在使用的html如下所示。我正在尝试选择第二个“确定”按钮:
你试过使用nth吗
或者尝试使用aria labelledby的选择器
如何打开第二个模式?第二次单击是否会打开第二个模式?没错,单击LayerDeletingPopUpButtonID会导致渲染第二个打开的模式
const modalOKButton = Selector('div.ant-modal').nth(1)
.find('div.ant-modal-footer')
.find('button.ant-btn-primary');
const modalOKButton = Selector("[aria-labelledby='rcDialogTitle1']")
.find('div.ant-modal-footer')
.find('button.ant-btn-primary');