0

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)
    }      
Rotem
  • 1
  • You might need to explicitly wait, or wait for an element before you can click it. E.g., there will be some time required between the form submitting and loading the next page during which, if you try to click on something—it won't exist because the page hasn't loaded – Marco Lüthy Feb 09 '18 at 15:20
  • For the record, I believe an `await` keyword is missing on the first line of the `try` block. – Otto G Apr 19 '18 at 14:25

1 Answers1

0

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.

Otto G
  • 670
  • 7
  • 14