angularjs - how to find element in protractor test? -
trying check value of element on angular plunker:
it('should display valid',function(){ browser.get('http://embed.plnkr.co/3nt01z/preview'); var errortext =element(by.xpath('body>div>h2>span:nth-child2)')).gettext); expect(errortext).tobe('not:('); })
getting error though:
stacktrace: invalidselectorerror: invalid selector: unable locate element xpath expression body>div>h2>span:nth-child(2) because of following error: syntaxerror: failed execute 'evaluate' on 'document': string 'body>div>h2>span:nth-child(2)' not valid xpath expression.
is there better way find span element or right xpath expression?
i think meant by.cssselector(...)
.
by.xpath
expects xpath expression, /body/div/h2/span[2]
, although i'm not sure exact syntax.
by way, code easier test if added id or css class element, don't need depend on exact dom structure.
Comments
Post a Comment