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 标记名jasmine和量角器未找到元素_Angular_Asp.net Mvc_Jasmine_Protractor_Angular E2e - Fatal编程技术网

Angular 标记名jasmine和量角器未找到元素

Angular 标记名jasmine和量角器未找到元素,angular,asp.net-mvc,jasmine,protractor,angular-e2e,Angular,Asp.net Mvc,Jasmine,Protractor,Angular E2e,我下面的测试总是失败,因为量角器无法通过标记名找到元素 it('should show test component',async () => { await browser.get('/trade') element(by.tagName(('test-component'))).isPresent() .then(value=>{ console.log(value ,'first') expect(value).toBeTruth

我下面的测试总是失败,因为量角器无法通过标记名找到元素

it('should show test component',async () => {
    await browser.get('/trade')
    element(by.tagName(('test-component'))).isPresent()
    .then(value=>{
      console.log(value ,'first')
      expect(value).toBeTruthy()
    });

})

我曾在其他测试规范中尝试过相同的代码,但效果不错。我做错了什么?

尝试使用下面的代码片段

it('should show test component', async () => {

await browser.get('provide complete url');

var EC = browser.ExpectedConditions;
await browser.wait(EC.visibilityOf(element(by.tagName('test-component'))),10000);

element(by.tagName('test-component')).getText().then(async (value)=>{
console.log(value ,'first')
expect(await value).toBeTruthy();

});

@Mokkasoru关闭为?@Mokkasoru这里的代码在语法上是正确的。我不确定你的评论指的是什么。它很有效,非常感谢!虽然我想知道,对于每个测试,我需要编写这么多的代码,但这取决于测试套件的结构。如果您在框架中使用了适当的挂钩,那么您就可以在挂钩中处理许多重复的任务,并在测试中执行特定于测试的任务。否则,您需要重复代码,这不是一个好的实践。