Testing templates in Protractor?

前端 未结 2 2098
栀梦
栀梦 2021-02-13 15:27

What\'s the best way to write assertions that should apply across every page in a site?

I\'m testing to see if an element exists in the footer of my site, so the element

2条回答
  •  囚心锁ツ
    2021-02-13 15:34

    I am using specs in a way that a spec speaks about some scenario, not always about particular page, so it's not "one spec, one page". I would consider that testing the same thing across many specs as bad practice if the conditions in specs can't influence the presence of your element.

    In general I don't think it's even necessary to test things like that. I would rather consider if it's even possible for your element not to be present or, if there are some conditions which influence that, and test those situations.

    If you insist on testing this (e.g. there are static pages which don't share content and your element is added by hand and you have to be sure), I would create single spec for testing the presence of this element and in there, define a list of pages to test. So the test would cover the testing of that element's presence on all the listed pages.

提交回复
热议问题