0

在我的一个测试中,我登录并转到下一页。在下一页中,当我尝试单击配置文件元素时,.click似乎什么也没发生。

当我使用该.exists函数时,它返回 false。

为什么更改 DOM 后chromeless 不能识别元素?

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)
    }      
4

1 回答 1

0

执行链中的前一个操作时,DOM 树中尚不可用的任何内容(除了goto()可能还有其他一些方法)都必须等待使用该wait()方法。

因此,假设这this.myProfile是要单击的元素的 CSS 选择器字符串:

// 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)

或者,可以将implicitWait Chromeless 构造函数选项设置为true,只要这不会对其他任何东西产生负面影响。

于 2018-04-19T14:23:54.123 回答