量角器测试-按钮元素不可单击

时间:2018-07-31 16:37:10

标签: javascript angular protractor automated-tests

手动执行:-单击登录按钮,它会导航到主页

自动执行相同的功能

HTML代码

<button _ngcontent-c1="" class="btn btn-primary sign-in" id="signInButton" 
 type="submit">
       <span _ngcontent-c1="">Sign in</span>
</button>

login.po.ts

loginButton = element(by.id('signInButton'));
login(email: string, password: string) {
this.emailField.clear();
this.setEmail(email);
this.passwordField.clear();
this.setPassword(password);
//this.loginButton.sendKeys(protractor.Key.ENTER) ;
//this.loginButton.click();

}

login.e2e-spec.ts

  it('with valid email and password -should display login page and login into app', () => {
  page.getLoginButtonText().then(function(text: string) {
    console.log(text);
  });
  page.login('testtest@gmail.com', 'testtest');
  browser.wait(EC.elementToBeClickable(page.loginButton), 10000, 'LoginButton not clickable');
  browser.actions().mouseMove(page.loginButton).click().perform().then(function() {
    console.log("LoginButton clicked!");
  });

当我在网页控制台上尝试document.getElementById('signInButton')。click()时 我得到“未定义”

 document.getElementById('signInButton').click()

未定义

0 个答案:

没有答案