簡體   English   中英

C#硒Xpath

[英]C# Selenium Xpath

我正在嘗試從DOM中選擇一個元素,但是我很努力。 基本上,我試圖選擇包含一些文本的標題屬性。 以下是我要整合的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;">

因此,我試圖選擇帶有包含文本“ AndyShort”的“ title”屬性的“ img”元素。 我已經嘗試過了,但是沒有用:

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

也,

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

有人可以幫忙嗎?

您應該檢查標題屬性

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM