lundi 23 novembre 2020

Testcafe, how to click a button on a modal popup?

I'm struggling to define a selector in TestCafe that clicks that button on the left called "start a car damage claim". This button appears on a modal popup .enter image description here

my code looks like

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 fails at the moment to find the selectors modal_popup on the popup, which selector can i use so TEstcafe can find the popup and then click the button???

Error displayed:

  1. AssertionError: Element not found: expected false to be truthy

async clickStartClaim(claimtype){ 88 | await t > 89 | .expect(this.modal_popup.exists).ok('Element not found', { timeout: config.general.shortTimeout })

Aucun commentaire:

Enregistrer un commentaire