简体   繁体   中英

How to get element with its style attribute in protractor?

i am new to use protractor. There is an html element which its only unique part is url of background image in style attribute. You can see below.

<div _ngcontent-jaf-c293="" class="ng-star-inserted" style="background-image: 
url(&quot;/assets/map-markers/vms-marker.png&quot;); background-repeat: no-repeat; 
background-size: 100% 100%; height: 44.1px; width: 27.5625px;"></div>

I tried to get this element.(see below)

 var created = element(by.xpath('//div[contains(@style,"background-image: url(\"/assets/map-markers/vms-marker.png\");")]'));

I am gettting syntax error. How to write expression to get this element? Or is it possible to get element with the style attribute?

var marker = element(by.xpath("//div[@style[contains(.,'vms-marker.png')]]")); worked

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