javascript - Protractor id of element dynamically generated - Stack Overflow

I want to know that is possible to find element by partial id, because on page which I'm testing i

I want to know that is possible to find element by partial id, because on page which I'm testing id is dynamic(The first part of the id has a variable number) and I can't know whole id.

I want to know that is possible to find element by partial id, because on page which I'm testing id is dynamic(The first part of the id has a variable number) and I can't know whole id.

Share Improve this question edited Jun 23, 2015 at 12:10 alecxe 475k127 gold badges1.1k silver badges1.2k bronze badges asked Jun 23, 2015 at 12:03 tealangtealang 2011 gold badge3 silver badges11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

There are multiple ways to do it, e.g. with a CSS selector:

// starts-with
element(by.css("div[id^=test]"));

// ends-with
element(by.css("div[id$=test]"));

// contains
element(by.css("div[id*=test]"));

Or, with an XPath (no ends-with here):

// starts-with
element(by.xpath("//div[starts-with(@id, 'test')]"));

// contains
element(by.xpath("//div[contains(@id, 'test')]"));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745153554a4613979.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信