Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 量角器在页面中找不到选择器_Angular_Redirect_Async Await_Protractor - Fatal编程技术网

Angular 量角器在页面中找不到选择器

Angular 量角器在页面中找不到选择器,angular,redirect,async-await,protractor,Angular,Redirect,Async Await,Protractor,我有这样一个密码: it('should go to summary page without sending the order', async () => { stepExecutor.startTimer(); // redirects, rather than checking logging await stepExecutor.executeStep(loginWithCustomer, { name: 'loginWithCustomer

我有这样一个密码:

it('should go to summary page without sending the order', async () => {
    stepExecutor.startTimer();
    // redirects, rather than checking logging 
    await stepExecutor.executeStep(loginWithCustomer, {
      name: 'loginWithCustomer',
      description: 'Page: login'
    });
    // 
    await stepExecutor.executeStep(selectFirstSubscription, {
      name: 'selectFirstSubscription',
      description: 'Page: abo first'
    });
});

async function loginWithCustomer() {
  const page = createLoginPage(browser.params.space);
  await page.navigateTo(browser.params.login.url);
  await page.enterLogin(browser.params.login.username, browser.params.login.password);
  await page.redirect(`${browser.baseUrl}${ABO_FIRST_URI}`);
}

async function selectFirstSubscription() {
  const page = new AboFirstPage();
  await page.closeCookieNotification();
  await page.selectFirstSubscription();
}

export class AboFirstPage {
  async selectFirstSubscription() {
    await element(by.css('.button--primary')).click();
  }
}
它向我暴露了一个错误:

- Failed: No element found using locator: By(css selector, .button--primary)

Executed 1 of 1 spec (1 FAILED) in 5 secs.
[18:04:59] I/launcher - 0 instance(s) of WebDriver still running
[18:04:59] I/launcher - chrome #01 failed 1 test(s)
[18:04:59] I/launcher - overall: 1 failed spec(s)
[18:04:59] E/launcher - Process exited with error code 1
但在重定向到(函数loginWithCustomer)的页面上,会出现这样一个选择器。 元素(by.css('.button--primary'))返回一个对象:
这段代码可能有什么错误?

让我们检查一下等待问题。将
sleep
添加到此函数:

async function selectFirstSubscription() {
  const page = new AboFirstPage();
  await page.closeCookieNotification();
  await browser.sleep(5000);
  await page.selectFirstSubscription();
}
若它可以工作,那个么您就有等待问题,在单击元素之前,您应该添加显式服务生。例如
wait ExpectedConditions.elementtobelickable(element)