chromeless- Clicking on an element in the next page is not working

151 Views Asked by At

On one of my tests I log in and move to the next page. In the next page when I try to click on the profile element with .click nothing seems to be happening.

When I use the .exists function it returns false.

Why can't chromeless recognize element after changing the DOM?

async  func(){            
   try {
     this.chromeless
    .goto(this.url)
    .click(this.switchToLogIn)                     
    .type(this.email, this.emaillAddressInput)
    .type(this.password, this.passwordInput)   
    .click(this.logInButton )
    .click(this.myProfile)
    .screenshot()        
    }
    catch(err) {
        console.log(err)
    }      
1

There are 1 best solutions below

0
Otto G On

Anything that was not already available in the DOM tree when the previous action in the chain was performed (with the exception of goto() and possibly some other methods) has to be waited for using the wait() method.

So, assuming that this.myProfile is a CSS selector string for an element to be clicked:

// Unchanged code omitted
.click(this.logInButton)
// Since the previous click loads a new page and/or shows new content, we need to wait
.wait(this.myProfile)
.click(this.myProfile)

Alternatively, the implicitWait Chromeless constructor option could be set to true, as long as that does not affect anything else negatively.