简体   繁体   中英

How to access a div tag content using protractor

I'm currently working on creating a test which will be able to click a link which is in a div. The problem is my developer has changed some part of the UI and as a result my XPath locator is not working. Also using Xpath is not feasible as in future some UI might change and I wont be able to locate the element.

My div tag looks like this and I want to perform a click on the div tag.

<div class="link verticalCenter" ng-click="replaceLocation('login')">Sign in</div>

PS: I can't use css locator for it.

Please let me know how can I achieve this.

尝试使用在DOM更改后仍然适用的相对XPath

//div[text()="Sign in"]

You still might use CSS, but with some special locator: element(by.cssContainingText('div', 'Sign in'))

http://www.protractortest.org/#/api?view=ProtractorBy.prototype.cssContainingText

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM