angularasp.net-mvcjasmineprotractorangular-e2e

Element not found by tagname jasmine and protractor


My below test always fails as protractor cannot find the element by tag name.

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()
    });

})

I have tried the same code in other test spec but it worked. What am I doing wrong here?


Solution

  • Try using the below code snippet.

    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();
    
    });