简体   繁体   English

C#硒Xpath

[英]C# Selenium Xpath

I am trying to select a an element from a DOM but I am struggling with. 我正在尝试从DOM中选择一个元素,但是我很努力。 Basically i am trying to select a title attribute that contains some text. 基本上,我试图选择包含一些文本的标题属性。 Below is a section of the DOM I am interegating:- 以下是我要整合的DOM的一部分:

   <div id="map" class="leaflet-container leaflet-fade-anim" style="position: relative;"tabindex="0">
          <div class="leaflet-map-pane" style="transform: translate(-13px, 109px);">
                  <div class="leaflet-tile-pane">
                  <div class="leaflet-objects-pane">
                           <div class="leaflet-shadow-pane">
                           <div class="leaflet-overlay-pane"></div>
                           <div class="leaflet-marker-pane">
                                    <img class="leaflet-marker-icon leaflet-zoom-animated leaflet-                      clickable leaflet-marker-draggable" src="https://lgw-fids.ultra.aero/fids//Scripts/leaflet-0.7.2/images/marker-icon-red.png" title="DEMO Last Connected: 05/09/2014 12:01:41" tabindex="0" style="transform: translate(818px, 256px) rotate(0deg); z-index: 256;">
                                    <img class="leaflet-marker-icon leaflet-zoom-animated leaflet-clickable leaflet-marker-draggable" src="https://lgw-fids.ultra.aero/fids//Scripts/leaflet-0.7.2/images/marker-icon-red.png" title="Retest_Device_4 Last Connected: " tabindex="0" style="transform: translate(992px, 266px) rotate(180deg); z-index: 266;">
                                    <img class="leaflet-marker-icon leaflet-zoom-animated leaflet-clickable leaflet-marker-draggable" src="https://lgw-fids.ultra.aero/fids//Scripts/leaflet-0.7.2/images/marker-icon-red.png" title="AndyShort Last Connected: 08/09/2014 15:25:05" tabindex="0" style="transform: translate(629px, 221px) rotate(0deg); z-index: 221;">

So I am trying to select the 'img' element with a 'title' attribute that contains the text 'AndyShort'. 因此,我试图选择带有包含文本“ AndyShort”的“ title”属性的“ img”元素。 I have tried this but it doesnt work:- 我已经尝试过了,但是没有用:

//div[@id='map']/div[1]/div[2]/div[3]/img[contains(text(),'AndyShort')]

Also, 也,

//div[@id='map']/div[1]/div[2]/div[3]/img[@title contains(text(),'AndyShort')]

Can anybody help? 有人可以帮忙吗?

您应该检查标题属性

//img[contains(@title, 'AndyShort')]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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