Javascript Testcafe,如何单击模式弹出窗口上的按钮?
我正在努力定义TestCafe中的选择器,该选择器单击左侧名为“启动汽车损坏索赔”的按钮。此按钮出现在模式弹出窗口中 我的代码看起来像Javascript Testcafe,如何单击模式弹出窗口上的按钮?,javascript,testing,automation,automated-tests,testcafe,Javascript,Testing,Automation,Automated Tests,Testcafe,我正在努力定义TestCafe中的选择器,该选择器单击左侧名为“启动汽车损坏索赔”的按钮。此按钮出现在模式弹出窗口中 我的代码看起来像 class PortalDashboard { constructor(){ //Selectors Portal this.welcome_user_message = Selector('#welcomeBack') this.topbar = Selector('#stateNavbar') this.footer =
class PortalDashboard {
constructor(){
//Selectors Portal
this.welcome_user_message = Selector('#welcomeBack')
this.topbar = Selector('#stateNavbar')
this.footer = Selector('.row footerSectionOne')
this.policy_summary = Selector('#policySummaryList')
this.logout_button = Selector('.logoutBtn')
this.my_claims = Selector('a[href="./claims"]')
this.view_motor_policy_details_link = (Selector('#policySummaryDetails_M0014157733').find('#claimLink_0'))
//Start a claim - Modal popup
this.motor_claim_modal = Selector ('#carAccidentDialog')
this.property_claim_modal = Selector('.claimDialog')
this.call_us_button = Selector('#callUsDesktop')
this.start_claim_button = Selector('#defaultFocus')
this.modal_popup=Selector('panel-body center')
}
async clickStartClaim(claimtype){
await t
.expect(this.modal_popup.exists).ok('Element not found', { timeout: config.general.shortTimeout })
.expect(this.call_us_button.exists).ok('Element not found', { timeout: config.general.shortTimeout })
.expect(this.start_claim_button.innerText).contains(claimtype)
.click(this.start_claim_button)
.setPageLoadTimeout(config.general.shortTimeout )
}
TestCafe此时无法在弹出窗口上找到选择器modal_弹出窗口
我可以使用哪个选择器,以便Testcafe可以找到弹出窗口,然后单击按钮
显示错误:
1 AssertionError:未找到元素:应为false,否则为true
异步ClickStartClaimType{
88 |等待t
>89 |.expectthis.modal_popup.exists.ok'Element not found',{timeout:config.general.shortTimeout}
我认为您的问题不在于按钮本身,而在于模式。请注意,错误在断言中: .expectthis.modal_popup.exists.ok 您的模态_弹出变量是选择器“panel-body center”,但您尚未声明是class.还是id 因此,构造函数中的变量应为:
this.modal_popup = Selector('.panel-body center')
^
This
如果不使用.or,TestCafe将查找标记div、button…的值,而panel body不是标记,而是类名。我认为您的问题不在于按钮本身,而在于模式。请注意,错误在断言中: .expectthis.modal_popup.exists.ok 您的模态_弹出变量是选择器“panel-body center”,但您尚未声明是class.还是id 因此,构造函数中的变量应为:
this.modal_popup = Selector('.panel-body center')
^
This
如果不使用.or,TestCafe将查找标记div、button…的值,面板主体不是标记,而是类名